Original Topic: Passing Arguments from the Command line

This updated version also allows a batch file to run kixtart commands with out having to actually be running a kixtart script.

Examples:
kixstart @ for $counter = 1 to 10 ? $counter sleep 1 next

kixstart @ ? @scriptdir

To use:
1. Copy the code below to Notepad and save the file as Kixstart.bat in the same directory as Kix32.exe

or
1. Rename Kix32.exe to something like Kix32_420.exe.
2. Copy the code below to Notepad
3. Modify the section named ":runkix" to:
kix32_420.exe %kixscript% %cmdline%
4. Save the file as Kix32.bat in the same directory as Kix32_420.exe.
5. Run kix32 for your scripts (but with more options)

Code:


::====================================================
::STARTUP_SCRIPT KIXSTART.BAT
::
::ACTION ALLOWS USER TO PASS EITHER KIXTART ARGUMENTS
:: OR CMD LINE ARGUMENTS TO KIXTART SCRIPT
:: OR RUN A KIXTART COMMAND FROM A COMMAND PROMPT
::
::AUTHOR ALLEN POWELL (AL_PO)
::
::VERSION 1.1
::
::REQUIRES CMD.EXE FROM WINDOWS NT 4.0, WINDOWS 2000, OR WINDOWS XP
::
::SYNTAX KIXSTART SCRIPTNAME SCRIPTARGS
::OR
:: KIXSTART @ KIXTARTCOMMAND
::
::PARAMETERS
:: SCRIPTNAME - .KIX FILE
:: SCRIPTARGS - EITHER $ARG1="SOMETHING" $ARG2="NOTHING"
:: OR /A /B /C /SOMETHING /D "NOTHING"
:: OR no args at all.
::
:: KIXTARTCOMMAND - NORMAL SYNTAX OF KIXTART COMMANDS
::
::
::ADDITIONAL IF USING CMD LINE ARGS, KIXSTART.BAT SETS $CMDARGS WHICH CAN
:: BE SPLIT AND THEN PROCESSED IN THE KIXTART CODE.
::

@echo off
if not %OS%==Windows_NT goto help
if "%1"=="/?" goto help
if "%1"=="" goto help
set kixscript=%1
for /f "tokens=1* delims= " %%f in ("%*") do call :DetermineArgType "%%g"
goto end

:DetermineArgType
if %1=="" set cmdline= & goto runkix
set args=%1
set args=%args:~1,-1%
if %kixscript%==@ echo %args%>%temp%\tmp.kix & set kixscript=%temp%\tmp.kix & set cmdline= & goto runkix
if %args:~0,1%==$ set cmdline=%args% & goto runkix
if %args:~0,1%==/ set cmdline=$cmdargs="%args%" & goto runkix
goto :eof

:runkix
kix32 %kixscript% %cmdline%
goto end

:help
cls
echo 
echo.
echo KIXSTART.BAT is a startup script for KIX32.EXE.
echo.
echo KIXSTART.BAT can use EITHER kixtart arguments ($arg1="blah blah blah")
echo OR Command arguments preceded with a "/" (/a "hello" /b /c /etc)
echo OR no arguments at all.
echo.
echo To use Command arguments in Kixtart add the following to the beginning
echo of your Kixtart code:
echo.
echo if $cmdargs^<^>""
echo $params=split($cmdargs,"/")
echo for each $param in $params
echo {your code here}
echo next
echo endif
echo.
echo KIXSTART.BAT requires an NT based OS: Windows NT 4, Windows 2000, Windows XP,
echo or higher.
echo.
echo Syntax: Kixstart Scriptname ScriptArgs
echo.
:end