VoiceAttack
Profiles, Commands and Plugins => Profile and Command Discussions => Topic started by: Panaue on March 07, 2025, 01:01:59 PM
-
I have a command to set up to 10 bookmarks, for recall in other commands, and was wondering if it could be done in a way that I don't have to repeat for all 10 bookmarks.
Command is: Save to bookmark[1..10]
Set text [~Input] to '{CMDSEGMENT:1}'
Set text [~clip] to '{CLIP}'
Begin Text Compare : [{CMDSEGMENT:1}] Equals '1'
Begin Text Compare : [Bookmark1] Has Not Been Set
Set text [Bookmark1] to '{CLIP}' (Upper Case) (save value to profile)
Say, '{TXT:Bookmark1} has been saved to Bookmark 1.'
Else If Text Compare : [Bookmark1] Has Been Set
Say, 'Bookmark has already been saved to {TXT:Bookmark1}, would you like to overwrite this? Yes or No!'
Wait for spoken response: 'Yes;No'
Begin Text Compare : [{TXT:~textResult}] Equals 'Yes'
Set text [~temp] to [{TXT:Bookmark1}]
Say, 'Bookmark {TXT:Bookmark1} has been overwritten with [{CLIP}]'
Pause 0.1 seconds
Set text [Bookmark1] to '{CLIP}' (save value to profile)
Else
Say, 'Bookmark {TXT:Bookmark1} as not been overwritten!'
End Condition
End Condition
End Condition
Thanks in advance!!
-
You can use tokens combined with text in order to form dynamic variable names which you can use in your comparisons like this:
Set text [~thisBookmark] to [Bookmark{CMDSEGMENT:1}]
Begin Text Compare : [~thisBookmark] Has Not Been Set
Write [Red] 'TESTING: This bookmark has not been set (yet)' to log
Set text [Bookmark{CMDSEGMENT:1}] to '{CLIP}' (Upper Case) (save value to profile)
Say, '{TXT:Bookmark{CMDSEGMENT:1}} has been saved to Bookmark {CMDSEGMENT:1}.'
Else If Text Compare : [~thisBookmark] Has Been Set
Write [Green] 'TESTING: This bookmark has already been set' to log
End Condition
That should help you make this into a single ambiguous condition without having to write out conditions for each bookmark number (thus eliminating the need to repeat same-same actions over and over).
Best wishes and good luck!!
-
Just as a follow up to save you time, note that I placed the value of the (dynamic) variable into a text variable, and used that in the condition, as opposed to assembling the dynamic variable name directly within the condition.
This works:
Set text [~thisBookmark] to [Bookmark{CMDSEGMENT:1}]
Begin Text Compare : [~thisBookmark] Has Not Been Set
...however, this would not work:
Begin Text Compare : [Bookmark{CMDSEGMENT:1}] Has Not Been Set
-
Thank you!! This worked wonderfully. I just started working with the dynamic variables and it this option did not occur to me even though I have used a similar concept in other commands.