Page 1 of 1 1
Topic Options
#100447 - 2003-04-20 06:58 AM Passing Arguments from the Command Line
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Since I am new to this forum I was wondering if we could address something that may have already been solved. From some old posts, I see that a number of people have asked if there is a way to pass arguments to kixtart that are not specifically $variable1, $variable2, but instead are like /c /e /a etc, or for kixtart to offer a @commandline.

As far as I know @commandline still does not exist. I think I have a very simple way to do this, but before I spend any more time on it, I wanted the veterans to let me know if this has already been solved.

Thanks.

Top
#100448 - 2003-04-20 07:07 AM Re: Passing Arguments from the Command Line
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Definitely hasn't been solved, love to hear your idea ...
Top
#100449 - 2003-04-20 06:13 PM Re: Passing Arguments from the Command Line
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
As documented in the KiXtart Manual, the only way for KiXtart to accept commandline arguments is to use variable assignments, such as
code:
kix32.exe script.kix $var="whatever"

Howver, one can always pass empty parameters as demonstrated below to resemble commmand-line arguments
code:
kix32.exe script.kix $c

code:
break on
dim $iRC
$iRC=SETOPTION('Explicit','on')

if isdeclared($c)
? 'Parameter C has been passed'
else
? 'Parameter C has not been passed'
dim $c
endif



[ 20. April 2003, 18:47: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#100450 - 2003-04-20 06:37 PM Re: Passing Arguments from the Command Line
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well, I'm still waiting for al to post his idea, I've been sitting here hitting F5 for 12 hours now [Frown] [Wink]
Top
#100451 - 2003-04-20 06:46 PM Re: Passing Arguments from the Command Line
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You don't have BBChecker? Man, are you retro! [Smile]
_________________________
There are two types of vessels, submarines and targets.

Top
#100452 - 2003-04-20 06:50 PM Re: Passing Arguments from the Command Line
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I do use bbc, just that I cant work on kf and run bbc at the same time ... dll in use [Frown]
Top
#100453 - 2003-04-20 07:58 PM Re: Passing Arguments from the Command Line
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
[Big Grin] Sorry to keep you guys waiting... I'll post some code later this evening...
Top
#100454 - 2003-04-21 02:37 AM Re: Passing Arguments from the Command Line
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Okay... here is solution 1.

[Smile] Positives: It works under NT OSs.
[Frown] Negatives: Will not work under Win9x, WinME.

While you guy tear this one apart [Wink] I've got another "all most" working solution to post that maybe someone can finish.

::====================================================
::STARTUP_SCRIPT KIXSTART.BAT
::
::ACTION ALLOWS USER TO PASS EITHER KIXTART ARGUMENTS
:: OR CMD LINE ARGUMENTS TO KIXTART SCRIPT
::
::AUTHOR ALLEN POWELL (AL_PO)
::
::VERSION 1.0
::
::REQUIRES CMD.EXE FROM WINDOWS NT 4.0, WINDOWS 2000, OR WINDOWS XP
::
::SYNTAX KIXSTART SCRIPTNAME SCRIPTARGS
::
::PARAMETERS SCRIPTNAME - .KIX FILE
:: SCRIPTARGS - EITHER $ARG1="SOMETHING" $ARG2="NOTHING"
:: OR /A /B /C /SOMETHING /D "NOTHING"
:: OR no args at all.
::
::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 %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

Top
#100455 - 2003-04-21 02:47 AM Re: Passing Arguments from the Command Line
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Possible Solution #2

[Smile] Positives: Works with all OSs. In its current state, I believe it will work with cmd line args.
[Frown] Negatives: Incomplete. It appears that the CSCRIPT parser removes quotes regardless of reason. This makes it impossible to pass kixtart arguments through it

Any ideas?

'kixstart.vbs
set cmdargs=Wscript.arguments
if cmdargs.count=0 then
call help
wscript.quit 1
elseif cmdargs.item(0)="/?" then
wscript.echo "/?"
call help
wscript.quit 1
elseif cmdargs.count>=1 then
kixscript=cmdargs.item(0)
for i = 1 to cmdargs.count - 1
cmdline=cmdline + cmdargs(i) + " "
next
select case left(cmdargs.item(1),1)
case "/"
cmdline="$cmdargs=" + cmdline
case "$"
case else
call help
wscript.quit 1
end select
else
call help
wscript.quit 1
end if

wscript.echo "kix32 " + kixscript + " " + cmdline

sub help
wscript.echo "help"
end sub

Top
#100456 - 2003-04-21 02:53 PM Re: Passing Arguments from the Command Line
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Another solution is to not use '/a'-style command-line arguements at all. Or alternatively, put the command-line args into an environment variable that you then access from within KiXtart.

However, why do you need to use '/a' if for example $a or $a="test" would work, too, as I demonstrated in my post above?
_________________________
There are two types of vessels, submarines and targets.

Top
#100457 - 2003-04-21 03:42 PM Re: Passing Arguments from the Command Line
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Kixtart was the first scripting language I have used that did not accept practically anything for an argument after the script. As an example, back in the DOS days and even today with some of the apps you can use, the generally well known syntax to get help is: app.exe /?, not app.exe $help="/?". Granted, if there are no args after the app.exe you could still show help. However, for myself I would like to be able to use the old style for consistency sake.

My idea was to write a bat file that not only accepted the preconceived way of sending arguments to a kixtart script, but also give a pseudo @commandline option for people who, like myself, like to use the "/" options. KIXSTART.BAT gives me that option. To make this work I have renamed my kix32.exe to kix32-420.exe. Then I renamed the kixstart.bat to kix32.bat and modified the code to point to the kix32-420.exe file. Now either type of arguments is accepted by a kixtart script.

Top
#100458 - 2003-04-23 06:27 PM Re: Passing Arguments from the Command Line
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
It's been oddly quiet... I was kind of wondering what everyone's thoughts/ideas are of this bat file.

Have I written something only I will use? [Wink]

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 544 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.071 seconds in which 0.032 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org