Executing Long Commands

Creating macros. Working with QM.

Executing Long Commands

Postby maximan on Thu Sep 07, 2017 3:35 am

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:

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


Example how to run it:
MY_PROGRAM :run "PROGRAM" "SRLP1" "SRLP2"


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


Thank you so much
maximan
 
Posts: 3
Joined: Thu Sep 07, 2017 3:21 am

Re: Executing Long Commands

Postby Gintaras on Thu Sep 07, 2017 4:46 am

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     ?
;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     ?
MY_PROGRAM :run g_PROGRAM g_SRLP1
MY_PROGRAM 2 :run "%DIR1%\Program.exe"

Gintaras
Site Admin
 
Posts: 10385
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Executing Long Commands

Postby maximan on Thu Sep 07, 2017 2:03 pm

Great! I used init2 and menu.

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


and another (preferred) variation:
MY_PROGRAM :run g_PROGRAM /S g_SRLP1 /S g_SRLP2
maximan
 
Posts: 3
Joined: Thu Sep 07, 2017 3:21 am

Re: Executing Long Commands

Postby Gintaras on Thu Sep 07, 2017 3:34 pm

Menu Menu59     ?
MY_PROGRAM :run g_PROGRAM F"/S {g_SRLP1} /S {g_SRLP2}"
MY_PROGRAM :run g_PROGRAM F"/S ''{g_SRLP1}'' /S ''{g_SRLP2}''"

Gintaras
Site Admin
 
Posts: 10385
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Executing Long Commands

Postby maximan on Thu Sep 07, 2017 5:45 pm

Outstanding, thank you so much.
maximan
 
Posts: 3
Joined: Thu Sep 07, 2017 3:21 am


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests

cron