Single Line IF Statements

Started by KeithW, September 11, 2020, 02:40:03 PM

Previous topic - Next topic

KeithW

Greetings,

In reading the fine manual I was understanding that the following IF statement syntax should be valid


j=1
k=1
l=1
m=1
n=1
for i = 2 to 6
if array[i,0] == ""  Then array[i,0] = array[j,0]  Else  j = i
if array[i,1] == ""  Then array[i,1] = array[k,1]  Else k = i
if array[i,2] == ""  Then array[i,2] = array[l,2]  Else  l = i
if array[i,3] == ""  Then array[i,3] = array[m,3]  Else m = i
if array[i,4] == ""  Then array[i,4] = array[n,4]  Else  n = i
Next


when the code is executed I get a:  "3074: Expression continues past expected end"

I verified there are no other characters at the end of the IF lines...  is this syntax illegal?

Keith

td

No, it is not vaild immediate if statment syntax.  The correct syntax is:

if array[i,0] == ""  Then array[i,0] = array[j,0]
Else  j = i

You can have multiple then or else statements after the initial if-then but each must be on their own line.  Of course, it is usually just better to just use the structured if at that point.
if @true
  <statememt>
  <statement>
else
  <statememt>
  <statement>
endif 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

KeithW

TD,

At least it was a simple and easy fix... was going by the following at the bottom of the IF .. stuff in the Consolidate WIL Manual right above the  Parameters: discussion...  last example of syntax...

if ... then ... else ... (single statement):

if expression then statement
else statement

misunderstood the ELSE had to be on a separate line.

Thanx,
Keith

td

In WIL syntax a statement is not necessarily synonymous with a single line.  Assigning a multi-line string to a variable is another example of a statement that consists of multiple lines.

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade