I've created this section to act as a common place to stuff macros you've written which may be of interest to others. Please try and make the subject line descriptive of what the macro basically does, and include comments in the text about usage, parameters, etc. You can either include the macro as inline code, like this.
' DOS.MACRO ' Open a DOS command window ' Syntax: DOS ' ' Author: George Deluca ' SPF_Cmd("CMD CMD.EXE") stop
This is a good illustration of the technique, though there are other ways (as usual) to handle this particular task.
First, the CMD command already launches the CMD.EXE command prompt window, so the call could be simplified to
Second, because there is already a command that does what is needed, it can be accomplished without a macro, by defining an alias. This can be done by going to any Edit window, and typing in the command
SET ALIAS.DOS = CMD
Then, you can type in DOS and it will be treated the same as the existing CMD command.
Now, if you needed to do something special, such as launching CMD.EXE with special parameters, etc. then George's example is a good model for writing such a macro command.
(These are all 7.0 features, so if you read about them now, you'll just have to wait until 7.0 is released to try them.)
This might be a good general purpose model, since it has a number of key factors: checking the run mode of the macro, getting the line range, iterating over the range of lines, and making a modification to each line.
' LJ.MACRO ' Left-Justify a line range by removing all leading blanks ' Syntax: LJ or LJJ/LJJ as line commands
dim LPTR1, LPTR2, i as number
if not is_line_cmd then Set_Msg(FAIL, "LJ macro must be invoked as a line command") stop end if
LPTR1 = get_src1_lptr ' get the line numbers LPTR2 = get_src2_lptr
for i = LPTR1 to LPTR2 ' for each data line, trim leading blanks and replace line if is_data(i) then set_line(i,LTRIM$(get_line$(i))) end if next