Pointer any to FC

Asbuild

Member
Join Date
Jun 2005
Location
Gent
Posts
12
Hallo,

Can somebody help mee.
I write a function to convert a DWORD to CHAR but i have problems with de pointer any.
See mij code

CALL "Second_ASQII"
OTZwaarde :=DB15.DBD64 //DWORD in DB15
DBString :=P#DB41.DBX210.0 //DB41= DWORD to char
StringFile:='A'

The string in DB41 = 'A000000_04' and begin on byte 210

FC1

L P##DBString //any pointer
LAR1
L D [AR1,P#2.0]
T #iDBArea
L W [AR1,P#4.0]
T #iDBNummer
L D [AR1,P#6.0]
T #IDBBereik
OPN DB [#iDBNummer]
LAR1 P#2.0
L #StringFile
T DBB [AR1,P#0.0]
L ' '
T DBW [AR1,P#3.0]
L ' '
T DBW [AR1,P#5.0]
L ' '
T DBW [AR1,P#7.0]
L ' '
T DBW [AR1,P#9.0]
L ' '
T DBB [AR1,P#11.0]

thanks
Jacques
 
If you post in symbolic form, we can't tell what "Second_ASQII" is. Is it FC1 of which you've shown a part ?

In your FC1 code you are not doing anything with the area pointer which you store in IDBBereik but you load AR1 with P#2.0, this means that
T DBB[ar1,p#0.0] will actually reference DBB2. I think you need to add P#2.0 to IDBBereik and use this in the address register. (Your code is putting spaces in the string)
 
Hallo,

Thanks for your anser.

Yes "Second_ASQII" = FC1
thats my problem.
IDBBereik = 212 is the area position in the DB (=DBX212.0)
How must i do that Lar1 = P#212.0?
 
One thing I see wrong is the "L D[AR1,P2.0]" statement. It should be "L D[AR1,P#0.0]" instead. I can't see where you are using IDBArea though, so maybe it isn't hurting anything right now.

And Simon is right. If you are using true Siemens strings (where the first two bytes are used for string lengths), then you have to add two bytes to the pointer, such as this:

L #IDBBereik
LAR1
+AR1 P#2.0

Now, you will be pointing to DBB212.

But then in the following code, you aren't writing to all of the bytes. Try this:

L #StringFile
T DBB [AR1,P#0.0]
L ' '
T DBB [AR1,P#1.0]
L ' '
T DBB [AR1,P#2.0]
L ' '
T DBB [AR1,P#3.0]
L ' '
T DBB [AR1,P#4.0]
L ' '
T DBB [AR1,P#5.0]
etc, etc

Or, you could write to words if you insert an extra space so you are transfering two bytes:

L #StringFile
T DBB [AR1,P#0.0]
L ' '
T DBW [AR1,P#1.0]
L ' '
T DBB [AR1,P#3.0]
L ' '
T DBB [AR1,P#5.0]
etc, etc
 

Similar Topics

I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
533
I am trying to access the value of a pointer via OPC UA in Codesys. I can share it directly and in a struct but I cant access the value of it when...
Replies
5
Views
1,610
Why does my deconstruction of the input pointer only work with its own instance DB not inside the multi instance FB...See .doc The pointer at the...
Replies
8
Views
2,342
Hi All, in many library function of TiaPortal some data must be write using the pointer format........ eg.: P#DB90.DBX0.0 WORD 10 is it...
Replies
5
Views
2,818
I have a very strange issue and I cannot figure out why it is not working. I read input of type pointer and store it to local temp type any. I...
Replies
4
Views
1,930
Back
Top Bottom