Author Topic: PLEASE help with this code  (Read 1821 times)

HansNel

  • Guest
PLEASE help with this code
« on: July 05, 2018, 03:11:06 AM »
Hi guys, I found this code snippet on this forum.
My question is, WHERE does one go to enter code examples from this forum, to test it?
THIS code check if I have "Dorico" running at that precise time, so WHERE do I enter these lines of code,

// Store name of process of interest in text variable. You can also use wildcards (*)
Set Text [~~MyProcess] to 'notepad'

// Check if process exists
Begin Text Compare : [{PROCESSEXISTS:~~MyProcess}] Equals '1'
    // Output info to event log
    Write ' The process exists!' to log
Else
    // Output info to event log
    Write ' The process does not exist' to log
End Condition


Thanks guys!
Hans

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: PLEASE help with this code
« Reply #1 on: July 05, 2018, 04:58:48 PM »
Most of the examples you see(with exception of those using C# or VB.net) are a representation of what the action list of your command would look like.

The examples will illustrate how your command can be made to work, however it is not possible to copy-paste that text into VoiceAttack to make a command directly.
The command can be recreated by adding the appropriate actions to your command in the given order, with the given parameters.

E.G.
Code: [Select]
Set Text [~~MyProcess] to 'notepad'is a "Set a Text Value" action, with the "Variable Name" field set to "~~MyProcess", and the "Text" field set to "notepad".

and
Code: [Select]
Begin Text Compare : [{PROCESSEXISTS:~~MyProcess}] Equals '1'is a "Begin a Conditional (If Statement) Block" action, with the "Text" tab selected, the "Variable Name / Token" field set to "{PROCESSEXISTS:~~MyProcess}", and the "Text" field set to "1".

The lines beginning with "//"(This has no significance in VoiceAttack, but is used by the author of your example to mimic C style comments, where two forward slashes tell the compiler to ignore whatever comes between them and the nearest new line marker, in order to indicate visually that they're comments)  are "Add a Comment to the Action List" actions, which do nothing functionally and could be left out, but serve to further clarify the example.
« Last Edit: July 05, 2018, 05:06:45 PM by Pfeil »

HansNel

  • Guest
Re: PLEASE help with this code
« Reply #2 on: July 06, 2018, 07:48:02 AM »
Thank you Pfeil :)