Post by R on Feb 12, 2023 15:48:55 GMT -5
The new FM line command W allows you to launch a Windows command that uses the name of the FM file as its Windows command line argument, such as "W NOTEPAD".
This is a big improvement and should prove handy. However, this command has a drawback, which is that you must type out a possibly long Windows command-line name every time you use this. That could get old fast if you used it a lot.
To overcome this drawback, I wrote a macro to allow you to make an abbreviation of any command you wish, even ones that might require a fully-qualified file name to run.
The idea goes like this. You first write your own "launcher" macro to define the short name of how you want to launch your Windows command. It's just a three line macro, that ends with an #INCLUDE to do the bulk of the work. You can make this use any naming convention you want. I will show you how I did it.
Let's say you want the "launcher" names to all start with W. as a prefix. Let's make one to launch NOTEPAD, and call it W.N.MACRO.
Here is what the launcher macro looks like. Except for the WinCmd string value, all launchers will look the same:
Then, you put W.N as an FM line command when you want to launch NOTEPAD.
This way, you can create as many launchers as you like. Using just one letter gets you up to 35 short names of these macros (leaving W.0 reserved).
Again, you can use any naming convention you want for all this. Here the W.0.MACRO I wrote for this:
This is a big improvement and should prove handy. However, this command has a drawback, which is that you must type out a possibly long Windows command-line name every time you use this. That could get old fast if you used it a lot.
To overcome this drawback, I wrote a macro to allow you to make an abbreviation of any command you wish, even ones that might require a fully-qualified file name to run.
The idea goes like this. You first write your own "launcher" macro to define the short name of how you want to launch your Windows command. It's just a three line macro, that ends with an #INCLUDE to do the bulk of the work. You can make this use any naming convention you want. I will show you how I did it.
Let's say you want the "launcher" names to all start with W. as a prefix. Let's make one to launch NOTEPAD, and call it W.N.MACRO.
Here is what the launcher macro looks like. Except for the WinCmd string value, all launchers will look the same:
' W.N.MACRO
DIM WinCmd AS STRING = "NOTEPAD"
#INCLUDE W.0.MACRO
Then, you put W.N as an FM line command when you want to launch NOTEPAD.
This way, you can create as many launchers as you like. Using just one letter gets you up to 35 short names of these macros (leaving W.0 reserved).
Again, you can use any naming convention you want for all this. Here the W.0.MACRO I wrote for this:
' W.0.MACRO
'
' This macro allows you to execute a Windows command from a line-cmd field in FM.
' To use:
'
' 1. Create a macro like this:
'--------------------------------------------------------------
' ' W.name.MACRO
' --> where "name" is the name of the W. macro you want
'
' DIM WinCmd AS STRING = "prog"
' --> where "prog" is the name of the desired program or bat file
'
' #INCLUDE W.0.MACRO
'--------------------------------------------------------------
'
' 2. Example: W.N.MACRO to launch NOTEPAD
'--------------------------------------------------------------
' ' W.N.MACRO
' DIM WinCmd AS STRING = "NOTEPAD"
' #INCLUDE W.0.MACRO
'--------------------------------------------------------------
'
' 3. Enter W.N as a FM line command on the desired line that you want NOTEPAD to edit
'
' 4. Create your own W.name.MACRO named as you wish
IF is_fm = 0 OR is_line_cmd = 0 THEN HALT("W.name must be entered in FM line cmd area")
DIM Fnum AS LONG = VAL(Get_Arg$(1))
DIM Fname AS STRING = FMGet_FileName$(Fnum)
DIM Fpath AS STRING = FMGet_Path$(FNum)
DIM fullname AS STRING = Fpath + Fname
DIM rc AS LONG
rc = SPF_Shell (ASYNC, HIDDEN, WinCmd, SPF_Quote$(fullname))
HALT(0)