Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Executing Long Commands
#1
This should be a simple question for the gurus.
I would like to somehow set (say in a variable) the long string of the full path of a program.exe,
and the long strings of the parameters being passed. Then to execute the program with the short variables.

Example:

Code:
Copy      Help
PROGRAM = C:\Users\username\AppData\Local\SomeProgram\Program.exe
SRLP1 = SomeReallyLongParameter1
SRLP2 = SomeReallyLongParameter2
SRLP3 = SomeReallyLongParameter3
SRLP4 = SomeReallyLongParameter4
SRLP5 = SomeReallyLongParameter5

Example how to run it:
Code:
Copy      Help
MY_PROGRAM :run "PROGRAM" "SRLP1" "SRLP2"

Instead of:
Code:
Copy      Help
C:\Users\username\AppData\Local\SomeProgram\Program.exe "SomeReallyLongParameter1" "SomeReallyLongParameter2"

Thank you so much
#2
In scripts of type macro and function you can use simple variables.
In scripts of type menu, toolbar and autotext there is no way to use simple variables common to all items. But can use global variables or environment variables. These must be set (once) in a function that runs before. I recommend to set them in function named "init2". It runs automatically at startup.

Function init2
Code:
Copy      Help
;global variables
str+ g_PROGRAM="C:\Users\username\AppData\Local\SomeProgram\Program.exe"
str+ g_SRLP1="SomeReallyLongParameter1"

;environment variables (supported only by some functions, at the start of file path strings)
SetEnvVar "DIR1" "C:\Users\username\AppData\Local\SomeProgram"
SetEnvVar "DIR2" "C:\Users\username\AppData\Local\OtherProgram"

Menu Menu59
Code:
Copy      Help
MY_PROGRAM :run g_PROGRAM g_SRLP1
MY_PROGRAM 2 :run "%DIR1%\Program.exe"
#3
Great! I used init2 and menu.

The final tweek is how to pass more than 1 parameters, like so:
Code:
Copy      Help
MY_PROGRAM :run g_PROGRAM g_SRLP1 g_SRLP2

and another (preferred) variation:
Code:
Copy      Help
MY_PROGRAM :run g_PROGRAM /S g_SRLP1 /S g_SRLP2
#4
Menu Menu59
Code:
Copy      Help
MY_PROGRAM :run g_PROGRAM F"/S {g_SRLP1} /S {g_SRLP2}"
MY_PROGRAM :run g_PROGRAM F"/S ''{g_SRLP1}'' /S ''{g_SRLP2}''"
#5
Outstanding, thank you so much.


Forum Jump:


Users browsing this thread: 1 Guest(s)