Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KOS ignores run command in FOR loop #609

Closed
mrantmet opened this issue Feb 22, 2015 · 2 comments
Closed

KOS ignores run command in FOR loop #609

mrantmet opened this issue Feb 22, 2015 · 2 comments

Comments

@mrantmet
Copy link

Hello,

writing first bug so excuse if didn't put enough information or asked stupid questions.
I have 2 scripts:
prog.ks:

SET L TO LIST().
L:ADD(1).
L:ADD(2).
FOR E IN L {
RUN subprog(E).
}

and subprog.ks:

DECLARE PARAMETER ListElement.
PRINT "subprog run with: " + ListElement.

KoS ignores command RUN in FOR loop in prog.ks.

When I "improve" prog.ks following way:

SET L TO LIST().
L:ADD(1).
L:ADD(2).
RUN subprog("dummy"). //this line is added to overcome the problem.
FOR E IN L {
RUN subprog(E).
}

Then subprog is run from all places correclty.

Could you please suggest whether it is a bug or I'm using RUN command in a wrong way? Thanks in advance.

//mrantmet

@Dunbaratu
Copy link
Member

Just tested and confirmed the problem.
Interestingly it's ONLY a problem with the FOR loop. The UNTIL loop works fine.

This was my test case:

testprog1.ks:

// dumb program to try calling another program in a loop.

SET things TO LIST().
things:ADD("AAA").
things:ADD("BBB").
things:ADD("CCC").

FOR thing IN things {
  RUN testprog2( thing ).
}.

testprog2.ks:

// dumb test program that just prints whatever you pass it in.

declare parameter printThis.

print printThis.

It just runs with no output at all.

If you change the loop in testprog1 from thsi:

FOR thing IN things {
  RUN testprog2( thing ).
}

to this instead:

SET i TO 0.
UNTIL i >= things:LENGTH() {
  RUN testprog2( things[i] ).
  SET i TO i +1.
}

then it works correctly and prints
AAA
BBB
CCC

@mrantmet
Copy link
Author

Hi Dunbaratu,

Glad to know it's fixed. Thanks!

//mrantmet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants