[?+]: Getting two character of a string and write in a DW

ProTool, WinCC flexible, WinCC, PP/OP/TP/TD/MP
Post Reply
reza662
Posts: 15
Joined: Wed Jan 26, 2011 1:24 pm

[?+]: Getting two character of a string and write in a DW

Post by reza662 » Mon Feb 25, 2013 12:58 pm

Hi Every body
First of all, I have to say I know only a little about writing script in wincc
so my question maybe is very simple! anyway,my question is:
I have a 17 characters string in an internal tag with " text tage 8-bit character set"
now I want to separate two character of this string and move these character to an external tag with word data format in the other words,
for example I have an internal tag with name "code" include 17characters like" ABEDOKHD569874125"
and I want to move second and 3rd character (BE) to an external tag with name "Type" in word format
but I don't know how can I do that?!
Is any help?
thanks

Homeroid_BL
Posts: 259
Joined: Fri Apr 03, 2009 3:24 pm
Location: Bosnia and Herzegovina

Re: [?]: Getting two character of a string and write in a DW

Post by Homeroid_BL » Tue Feb 26, 2013 8:29 am

Try something like this:

Code: Select all

a0$="ABEDOKHD569874125"

a1$=mid(a0$,2,2) (you get a1$="BE")

n1=asc(mid(a1$,1,1)) (you get n1=asc("B")=65, 0100 0001)
n2=asc(mid(a1$,2,1)) (you get n2=asc("E")=68; 0100 0100)

n=256*n1+n2; 0100 0001 0100 0100
n is a 16-bit integer, word.

reza662
Posts: 15
Joined: Wed Jan 26, 2011 1:24 pm

Re: [?]: Getting two character of a string and write in a DW

Post by reza662 » Tue Feb 26, 2013 1:42 pm

thanks Homeroid_BL
it works

Post Reply