Author Topic: Using the EXP function  (Read 384 times)

Uzaree

  • Newbie
  • *
  • Posts: 18
Using the EXP function
« on: June 29, 2024, 06:32:25 PM »
Can someone please look and tell me what my syntax error is?

Write {EXP: {INT:>Loop_Counter}=({INT:>Loop_Counter} -1) }

I am trying to write the number of loops left to the even log but I can't seem to get my sytax correct.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Using the EXP function
« Reply #1 on: June 30, 2024, 02:11:02 AM »
What you say this token combination is intended to do, and how it's currently structured, seem to be almost completely different things.

If you just want to see the value of the ">Loop_Counter" variable, all you need is
Code: [Select]
{INT:>Loop_Counter}
If you have a loop that's counting up, and want to check how many iterations remain (these examples assume a loop counting from 1 to 10), that could look like
Code: [Select]
{EXP: 10 - {INT:>Loop_Counter}}or, if you'd like count from 10 to 1 instead of from 9 to 0:
Code: [Select]
{EXP: 10 - ({INT:>Loop_Counter} -1)}(you could just use 11 instead, and do away with the -1, if you prefer; use what's most readable to you)



What you have currently is a statement that will be evaluated, as indicated by the "=" operator.
That means the output of the "{EXP:}" token will only ever be 0 for false, which is the only possible output in this case as you're comparing a number to that same number minus one, which will logically never be equal, or 1 for true.

Uzaree

  • Newbie
  • *
  • Posts: 18
Re: Using the EXP function
« Reply #2 on: June 30, 2024, 08:43:42 AM »
What I'm trying to do is change the >Loop_Counter veriable. so when it loops back it will pull the updated variable and count down.

Right now I have {EXP:{INT:>Loop_Counter} -1}  which writes the Loop_Counter - 1 value back to the event log but when it loops back to this statement it pulls the variable data again, which has not been changed, so the same number is written to the event log

example:
Loop_Varialbe = 7
 {EXP:{INT:>Loop_Counter} -1}

Writes 6

loops back through, Writes 6 again.  It should write 5

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Using the EXP function
« Reply #3 on: June 30, 2024, 08:48:03 AM »
What does the full action list for your command look like?

Right-click the action list, choose "Copy All as Text" from the context menu, then paste here into a code block

Uzaree

  • Newbie
  • *
  • Posts: 18
Re: Using the EXP function
« Reply #4 on: June 30, 2024, 08:53:28 AM »
Code: [Select]
Display window 'Window' As [Normal] (pause up to 2 Seconds for availability)
Set integer [>Loop_Counter] value to the converted value of {TXTNUM:"{CMDSEGMENT:2}"}
Start Loop : Repeat [{TXTNUM:"{CMDSEGMENT:2}"}] times 
    Write [Orange] '{EXP:1-{INT:>Loop_Counter} } Times left to cast.' to log
    Begin Text Compare : [{TXTNUM:"{CMDSEGMENT:1}"}] Equals '1'
        Start Loop : Repeat 5 times
            Pause 0.5 seconds
            Press Left Alt+1 keys and hold for 0.05 seconds and release
        End Loop
    Else If Text Compare : [{TXTNUM:"{CMDSEGMENT:1}"}] Equals '2'
        Start Loop : Repeat 5 times
            Pause 0.5 seconds
            Press Left Alt+2 keys and hold for 0.05 seconds and release
        End Loop
    Else If Text Compare : [{TXTNUM:"{CMDSEGMENT:1}"}] Equals '3'
        Start Loop : Repeat 5 times
            Pause 0.5 seconds
            Press Left Alt+3 keys and hold for 0.05 seconds and release
        End Loop
    Else If Text Compare : [{TXTNUM:"{CMDSEGMENT:1}"}] Equals '4'
        Start Loop : Repeat 5 times
            Pause 0.5 seconds
            Press Left Alt+4 keys and hold for 0.05 seconds and release
        End Loop
    Else If Text Compare : [{TXTNUM:"{CMDSEGMENT:1}"}] Equals '5'
        Start Loop : Repeat 5 times
            Pause 0.5 seconds
            Press Left Alt+5 keys and hold for 0.05 seconds and release
        End Loop
    Else If Text Compare : [{TXTNUM:"{CMDSEGMENT:1}"}] Equals '6'
        Start Loop : Repeat 5 times
            Pause 0.5 seconds
            Press Left Alt+6 keys and hold for 0.05 seconds and release
        End Loop
    Else If Text Compare : [{TXTNUM:"{CMDSEGMENT:1}"}] Equals '7'
        Start Loop : Repeat 5 times
            Pause 0.5 seconds
            Press Left Alt+7 keys and hold for 0.05 seconds and release
        End Loop
    Else If Text Compare : [{TXTNUM:"{CMDSEGMENT:1}"}] Equals '8'
        Start Loop : Repeat 5 times
            Pause 0.5 seconds
            Press Left Alt+8 keys and hold for 0.05 seconds and release
        End Loop
    End Condition
    Pause a variable number of seconds [{INT:>Timer}]
   
End Loop

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Using the EXP function
« Reply #5 on: June 30, 2024, 09:28:47 AM »
Try this:
Code: [Select]
Display window 'Window' As [Normal] (pause up to 2 Seconds for availability)
Set text [~keyToPress] to '[ALT]{TXTNUM:"{CMDSEGMENT:1}"}'
Start Loop : Repeat From [{TXTNUM:"{CMDSEGMENT:2}"}] to 1, using indexer [~i]
    Write [Blue] '{INT:~i} Times left to cast.' displayed as [Arrow Down]
    Start Loop : Repeat 5 times
        Pause 0.5 seconds
        Press variable key(s) [~keyToPress] and hold for 0.05 seconds and release
    End Loop
    Pause a variable number of seconds [{INT:>Timer}]
End Loop

Note that the "{TXTNUM:}" token is not necessary if the segment you're retrieving consists solely of a number.


Have you read the documentation on tokens?
Given that you don't have any actions that modify the value of the ">Loop_Counter" variable after it's been set initially, it looks like you're expecting a token to somehow affect the value of a variable, which it cannot.
Tokens retrieve information, they don't affect stored information.

You don't need to manually modify the variable value in this case anyway, as For loops have the option to set an indexer variable for you (I.E. "~i" in the above example).

Lastly, as you're using keys you can speak the name of, and they all perform the same input otherwise, you could consider using a variable keypress in the manner shown in the example, rather than your existing lookup structure.