CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version Spanish version French version
It is currently Mon Sep 01, 2014 7:28 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Oct 27, 2008 4:28 pm 
Offline

Joined: Tue Oct 21, 2008 3:12 pm
Posts: 9
Location: France
EDIT2 : Hello everydoby, I want to convert a BYTE to is corresponding ASCII string :
example :

a : INT ;
b : STRING;


a := 65; (*ASCII code => A*)

I would like the string 'A' in my var b ?
How can i do this ?

thank you

---------------------------------------

Hello, have you got examples using the library SysLibFileStream ?
Does it works with every PLC (can't find the corresponding document SysLibs_Overview.pdf) (In my case Moeller/Micro Innovation PLC)?

I've tried regarding ansi c definition but without any success :(

thank you :D


EDIT: On SysLibs_Overview.pdf from Moeller, they don't speak about SysLibFileStream, so I guess it doesn't work with ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 28, 2008 2:18 pm 
Offline

Joined: Tue Oct 21, 2008 3:12 pm
Posts: 9
Location: France
Regarding to my first question, I guess I may process like that

Code:
ascii:ARRAY[0..255] OF STRING(1):=33(' '), '!', '"','#','$$' ,'%' ,'&' ,'ยด','(' ,')' ,'*' ,'+' ,',' ,'-' ,'.' ,'/' ,'0' ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,':' ,';' ,'<' ,'=' ,'>' ,'?' , '@','A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y' ,'Z' ,'[','\' ,']' ,'^' ,'_' ,'`' ,'a' ,'b' ,'c' ,'d' ,'e' ,'f' ,'g' ,'h' ,'i' ,'j' ,'k' ,'l' ,'m' ,'n' ,'o' ,'p' ,'q' ,'r' ,'s' ,'t' ,'u' ,'v' ,'w' ,'x' ,'y' ,'z' ,'{' ,'|' ,'}' ,'~' ;


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 28, 2008 3:41 pm 
Offline

Joined: Fri Aug 25, 2006 10:33 am
Posts: 8
Location: Bad Honnef
Hi,

you are right. SysLibFileStream is not supported by Moeller PLCs.
If you have only 1 byte which holds the corresponding ASCII value you can copy it directly to the string:

s1 : string;
b1 : byte;
p1 : pointer to byte;

p1 := ADR(s1);
if ( b1 > 32 ) then
p1^ := b1;
else
p1^ := 32; (* blank *)
end_if
p1 := p1 + 1;
p1^ := 0; (* terminating zero *)

This is alternative to your string table which works too.

regards
Klaus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 7:59 am 
Offline

Joined: Sat Jun 24, 2006 4:14 pm
Posts: 44
Location: regensburg
in the open source library from oscat you can find such routines
www.oscat.de

_________________
freie sps bibliothek unter www.oscat.de


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 3:30 pm 
Offline

Joined: Tue Oct 21, 2008 3:12 pm
Posts: 9
Location: France
thank you for your answers

Softwerker59, I don't understand this part :

p1 := p1 + 1;
p1^ := 0; (* terminating zero *)

(I'm not realy fond of pointers)


hugo, thank you and great job, is there english documentation ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 6:26 pm 
Offline
Frequent User
Frequent User

Joined: Fri Dec 23, 2005 7:36 pm
Posts: 143
Location: Chicago, IL USA
Strings need a terminating character (0) so that the functions that use them know where the end of information contained within the string buffer is.

By moving a zero to the location that p1 is pointing at, you are putting that terminating character where it belongs in the string.

_________________
nOrM
=====
nOrM = Norman Dziedzic Jr.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2008 9:03 am 
Offline

Joined: Tue Oct 21, 2008 3:12 pm
Posts: 9
Location: France
thank you :)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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 Group