1

Can anyone help me on this script? What did the function do? Thanks!

========================================================

&AAA=0

if (string.scan(string.lwr("&parameters"),"AAA",0)!=-1)

( &AAA=1 )

========================================================

Nobody
  • 179
  • 2
  • 8

1 Answers1

2

Well I guess your code looks like this:

&AAA=0
if (string.scan(string.lwr("&parameters"),"AAA",0)!=-1)
(
  &AAA=1
)

Note: The round brackets for opening and closing a block in a PRACTICE script must be placed in separate lines.

About the meaning: Your script has two "variables" (aka. "macro"): &parameters and &AAA.

  • In the first line you initialize &AAA with 0.
  • In the second line you use string.lwr() to get the content of the variable &parameters converted to lower-case.
  • Then you search in this lower-case string for a string "AAA" (which is ironically upper case) beginning from the first letter (with string.scan()).
  • The result of string.scan() is -1 if the string "AAA" wasn't part of the lower-case version of &parameters
  • So variable &AAA gets set to 1, if a lower-case version of &parameters contain the string "AAA" (which is never the case since "AAA" is upper-case).

Maybe the writer of the script wanted to use string.upr() instead of string.lwr().

Holger
  • 3,920
  • 1
  • 13
  • 35
  • Hi Holger, thanks for your detailed answer. Just got two more questions: 1. what's the meaning of the 0 inside string.scan function? 2. why we compare the result of string.scan with -1? Thanks!! – Nobody Apr 11 '17 at 15:47
  • Goto http://www.lauterbach.com/manual.html and download ide_func.pdf and general_func.pdf. There you find a detailed explanation to the functions (Your function STRing.SCAN() is in ide_func.pdf). For understanding the script language itself I recommend training_practice.pdf – Holger Apr 11 '17 at 16:52