readln not advancing with counter in while loop

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
lavender
Newbie
Posts: 1
Joined: Tue Jan 15, 2019 7:00 pm

readln not advancing with counter in while loop

Post by lavender » Tue Jan 15, 2019 7:16 pm

readln not advancing to next record with counter variable %thisLineNbr%. I have verified that %thisLineNbr% is incrementing in each loop. It only reads line 3091. If change startingLineNbr to 3092, it reads the next line.

The readln code is:

Let>startingLineNbr=3091
Let>endingLineNbr=3100
Let>thisLineNbr=%startingLineNbr%
While %thisLineNbr%<=%endingLineNbr%
ReadLn>C:\\\inetdirs\\\NetSoft\\\MyVector\\\WebStorm\\\form\\\pifferTmp.soy,%thisLineNbr%,strLine
add>%thisLineNbr%,1
EndWhile

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: readln not advancing with counter in while loop

Post by Marcus Tettmar » Wed Jan 16, 2019 11:56 am

When assigning a variable never use the % symbols otherwise you are actually assigning the value to a variable named after the VALUE of the variable. %..% means value of. You don't want to assign to the value of you want to assign to the variable itself. Your While also needs a chevron. Here's what you need:

Code: Select all

Let>startingLineNbr=3091
Let>endingLineNbr=3100
Let>thisLineNbr=%startingLineNbr%
While>thisLineNbr<=endingLineNbr
  ReadLn>C:\inetdirs\NetSoft\MyVector\WebStorm\form\pifferTmp.soy,%thisLineNbr%,strLine
  Add>thisLineNbr,1
EndWhile
Note instead of the Add command you could do:

Let>thisLineNbr=thisLineNbr+1
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts