(view source code of kixmacro.kix as plain text)
; KixMacro.kix, Version 2.00 for Windows
; Creates a temporary batch file to store Kix
; macro results in an environment variable
;
; Written by Rob van der Woude
; http://www.robvanderwoude.com
;
; NOTE: This version of KixMacro.kix is NOT compatible with the
; previous version! The temporary batch file will now be
; written to a different location under a different name,
; so you need to modify the CALL command line following
; the invocation of the Kix script.
; Check command line parameters
IF $KixMacro = ""
GOTO Syntax
ENDIF
; Hide return codes
REDIRECTOUTPUT( "NUL" )
; Delete existing temporary batch file -- otherwise this
; script would append the result to the existing file.
IF EXIST( "%TEMP%.\_KixMacro.bat" )
DEL "%TEMP%.\_KixMacro.bat"
ENDIF
; Determine the name of the variable: if not specified, use default
IF $VarName = ""
$VarName = "KixMacro"
ENDIF
; Create the temporary file and write the result to this file,
; or display an error message if the file cannot be created or
; opened with write access.
IF OPEN( 1, "%TEMP%.\_KixMacro.bat", 5 ) = 0
EXECUTE( 'WRITELINE( 1, "SET $VarName=$KixMacro" )' )
REDIRECTOUTPUT( "" )
$err = 0
ELSE
REDIRECTOUTPUT( "" )
? "Error opening temporary file, errorcode = " + @ERROR
$err = 1
ENDIF
QUIT $err
:Syntax
CLS
? "KixMacro.kix, Version 2.00 for Windows"
? "Creates a temporary batch file to store Kix"
? "macro results in an environment variable"
?
? "Written by Rob van der Woude"
? "http://www.robvanderwoude.com"
?
? "Usage:"
? " KIX32 KixMacro.kix $$KixMacro=@@macro [ $$VarName=env_var ]"
? " CALL %%TEMP%%.\_KixMacro.bat"
? "Where:"
? " '@@macro' is any valid Kix macro name"
? " 'env_var' is the name of the environment variable that"
? " will hold the value of @@macro."
? " If no $$VarName is specified, the default name KixMacro"
? " will be used."
? "The second command calls the temporary batch file and stores"
? "the required value in the specified environment variable."
?
? "Press any key . . . "
REDIRECTOUTPUT( "NUL" )
GET $key
REDIRECTOUTPUT( "" )
CLS
? "Example:"
? "Executing the commands:"
?
? " KIX32 KixMacro.kix $$KixMacro=@@DAY $$VarName=WeekDay"
? " CALL %%TEMP%%.\_KixMacro.bat"
?
? "on friday will create a (temporary) batch file _KixMacro.bat"
? "(in the TEMP directory) containing one command line:"
? "SET WeekDay=Friday"
? "By calling this temporary batch file the day of the week is"
? "stored in the environment variable WeekDay."
?
? "See the Kix documentation for a list of available macros."
?
? "NOTE: This version of KixMacro.kix is NOT compatible with the"
? " previous version! The temporary batch file will now be"
? " written to a different location under a different name,"
? " so you need to modify the CALL command line following"
? " the invocation of the Kix script."
?
? "Press any key . . . "
REDIRECTOUTPUT( "NUL" )
GET $key
REDIRECTOUTPUT( "" )
QUIT 1
page last modified: 2024-04-16; loaded in 0.0068 seconds