Industry Online Support
Technical Forum
12/11/2007 11:09 PM | |
Posts: 3 Rating:
|
Hi there, I am trying to pass a String to a Function, but couldn't get the value of the string in the function. Here is what I did: 1. Define a STRING 'FF1234.56RT'in DB1 as test, so DB1.test will contain my string. 2. Create FC1, define i_String as an IN in FC1. 3. In FC1, I have the following codes: L P##i_String // Get the pointer pointing to the first byte of the input string LAR1 // Load AR1 with the address of the first byte of the string L B [AR1,P#1.0] // load the actual length of the string at the second byte T #length // store it in the variable #length T QB 0 4. In OB1, call FC1, i_String:=DB1.test. I get nothing in #length and QB0. But if in FC1, I OPN DB 1 and directly access the string in DB1, everything is fine, but that is not what I want. I need the string to be passed in. There seems to be nothing in i_String. I don't know how the passing in variables in S7 works, but please help!! Thanks!! AttachmentString2R.zip (225 Downloads) |
Last edited by: s7rookie at: 11.12.2007 23:09 |
|
12/12/2007 8:44 AM | |
Posts: 198 Rating:
|
hi, as you can see in the attached pictures when you use fb, your variables are ok and your scripts are working.. in short you can use that kind of pointing logic... when you use fc pointer will point v address which is memory area for fc s (i guess i have no idea actually :) and its not pointing as string length. So you will see blue and red circles in my second screen shot.. when you load string_1 to ar1 it points v 281 when you load string_2 to ar2 it pointsv 287 so length is 6 bytes 2 for db no , 4 for rest .. but it does not transfer actual data in to v area it just sends pointer... so in logic youcan't use itin your logic ... p.s : this just my point of view , i am not surebut TO LET IT WORK quick and go on YOU CAN CHANGE IT TO FB AS I TOLD. Attachmentpointing_string_fb_fc.zip (255 Downloads) |
Last edited by: Ates at: 12.12.2007 08:44 |
|
12/12/2007 9:16 AM | |
Joined: 4/24/2006 Last visit: 5/16/2023 Posts: 8586 Rating:
|
Hello s7rookie, Please have a look in online help of Step7, search for 'Permitted Data Type when transferring Parameters' Perhaps it's useful Alsoare these faq's: http://support.automation.siemens.com/WW/view/en/16848975 http://support.automation.siemens.com/WW/view/en/19106712 Best regards, Wizard |
Follow us on