CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Oct 15, 2019 3:04 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Nov 01, 2013 5:00 pm 
Offline

Joined: Thu Feb 07, 2013 12:40 pm
Posts: 3
Hi folks,
I am looking to use a WORD data type to store a unicode character - I have chosen the WORD datatype as this is the underlying data type of the WSTRING.

Basically I would like to be able to say:

Code:
VAR
    wTemp: WORD;
END_VAR

wTemp := "<";

and to have the hex value of < put into the variable.
---------------------------------------------------------------------------------
I have found a way around this problem but it is very un-eloquent and goes like this:

Code:
VAR
    wsTempString: WSTRING := "<";
    wTempWord: WORD;
END_VAR

wTempWord := wsTempString[0];



This has the desired effect of placing the hex value of < into wTempWord, but the readability of the program is awful, is there a way I can write the unicode character straight into the WORD variable.
I'm thinking of C in doing this:
Code:
temp = 'A';


Any help appreciated.

/Pete


Top
   
PostPosted: Fri Nov 01, 2013 9:01 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Tue Jun 06, 2006 9:03 am
Posts: 409
I don't know if a function for this already exists, but it is pretty easy to make:
Code:
FUNCTION WS_TO_W : WORD
VAR_INPUT
   WS   : WSTRING(1);
END_VAR
VAR
   pW : POINTER TO WORD;
END_VAR

Code:
pW := ADR(WS);
WS_TO_W := pW^;


Then call this from your application
Code:
wWord := WS_TO_W("<");


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited