Author Topic: Simple Loop Not Working...Any advice appbreciated.  (Read 2982 times)

Sim UK

  • Newbie
  • *
  • Posts: 12
Simple Loop Not Working...Any advice appbreciated.
« on: March 29, 2024, 05:28:28 AM »
I have two kids running around making loads of noise and causing mayhem....BUT this simple loop should be working?  Unless I have missed something really obvious?

Any help appreciated.

Code: [Select]
Set integer [TurnedAmount] value to 0
Set integer [TurnDegrees] value to the converted value of {CMDSEGMENT:0}
Write [Green] '{INT:TurnDegrees}' to log
Start Loop While : [TurnedAmount] Is Less Than Or Equals [TurnDegrees]
    Write [Red] 'LOOP' to log
    Set small int (condition) [TurnedDegrees] value as incremented by 5
    Write [Green] '{INT:TurnedDegrees}' to log
    Press A key and hold for 0.025 seconds and release
End Loop

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: Simple Loop Not Working...Any advice appbreciated.
« Reply #1 on: March 29, 2024, 05:35:58 AM »
What are the contents of the command's "When I say" field, and what is the log output on the main window when you execute the command?


As an aside, using a code block (click the # button) is recommended when posting action list contents.

Sim UK

  • Newbie
  • *
  • Posts: 12
Re: Simple Loop Not Working...Any advice appbreciated.
« Reply #2 on: March 29, 2024, 05:41:58 AM »
Thanks for the feedback (will try and incorporate).

when I say: [5;10;15;20;25;30;35] degrees to port

Output shows correctly the #of degrees as expected, but the loop never fires.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: Simple Loop Not Working...Any advice appbreciated.
« Reply #3 on: March 29, 2024, 06:04:23 AM »
Use the "Integer" tab for the "Loop Start" action. Also use the "Set an Integer Value" action to increment the value.

You're mixing two datatypes. "Integer" and "Small Integer" are not the same.
As an aside, the latter is deprecated and is not recommended for use in new commands (I.E. it exists to support old profiles).

Sim UK

  • Newbie
  • *
  • Posts: 12
Re: Simple Loop Not Working...Any advice appbreciated.
« Reply #4 on: March 29, 2024, 06:18:07 AM »
Thanks so much for you help.

I realised exactly what you said just before I read your post and changed the code accordingly.

Code: [Select]
Set small int (condition) [TurnedAmount] value to 0
Set small int (condition) [TurnDegrees] value to the converted value of {CMDSEGMENT:0}
Write [Green] '{INT:TurnDegrees}' to log
Start Loop While : [TurnedAmount] Is Less Than Or Equals [TurnDegrees]
    Set small int (condition) [TurnedAmount] value as incremented by 5
    Write [Green] '{SMALL:TurnedAmount}' to log
    Press A key and hold for 0.025 seconds and release
End Loop


As expected, a silly mistake on my part. 

Thank you for your help