Page 1 of 1 1
Topic Options
#112981 - 2004-02-01 11:50 PM Ordinary command line parameters
beerslayer Offline
Fresh Scripter

Registered: 2003-12-10
Posts: 15
Is it possible to pass an ordinary command line parameter to a KiX script?

For example, I want to call a KiX script with the following command line:

Quote:

openfile.kix myfile.txt



Now, before you scream "RTFM!" at me, I've read the manual enough to see that it is possible to do something like this:

Quote:

openfile.kix $filename="myfile.txt"



however, this causes me problems because the actual command line I need to send to the KiX script is being produced by another application whose sources I do not have access to, so I'm stuck with the output it wants to give, which does not include the $filename= part. (Massaging this output before sending it to the KiX script would defeat the purpose of writing this script using KiX rather than, say, Perl.)

In a DOS batch file, I can access any command line parameter using the %1, %2, etc. syntax. Is there anything directly comparable to this in KiX that I missed?
_________________________

Top
#112982 - 2004-02-01 11:54 PM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no.
well, you can access the commandline with a com-object but it does not help.
for some reason ruud has decided to not let us you commandline.
thus, with your wished syntax, kix will always try to execute your txt-file.
even though you get it readen.
so, you will end up with errors.
unless you destroy it in your first called script.
_________________________
!

download KiXnet

Top
#112983 - 2004-02-02 12:03 AM Re: Ordinary command line parameters
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You should be able to call KiX with a BATch file and pass parms to KiX that way.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112984 - 2004-02-02 04:05 AM Re: Ordinary command line parameters
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
While not an elegant solution, try my KixStart.bat script. Basically it tears the command line down and puts it into an array that you can use in your kixtart script.
_________________________
(... better days ahead)

Top
#112985 - 2004-02-02 04:35 AM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
boys boys.
I think you missed something.
afaik, he knows that he can use batch.
that wasn't what he asked.

he asked if that is also possible in kix.
_________________________
!

download KiXnet

Top
#112986 - 2004-02-02 04:41 AM Re: Ordinary command line parameters
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... if you are going to split hairs, he said:
Quote:

Is it possible to pass an ordinary command line parameter to a KiX script?



so the answer is "Yes" if you use an intermediary BATch file. :P
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112987 - 2004-02-02 04:44 AM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no, it then is no.
you would then pass it to batch, not kix.
_________________________
!

download KiXnet

Top
#112988 - 2004-02-02 04:49 AM Re: Ordinary command line parameters
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
But the BATch can reformat and pass it to KiX so indirectly, Yes.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112989 - 2004-02-02 08:32 AM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Quote:

In a DOS batch file, I can access any command line parameter using the %1, %2, etc. syntax. Is there anything directly comparable to this in KiX that I missed?




so, no.
_________________________
!

download KiXnet

Top
#112990 - 2004-02-06 09:45 PM Re: Ordinary command line parameters
beerslayer Offline
Fresh Scripter

Registered: 2003-12-10
Posts: 15
Thanks to all who responded.

I was trying to avoid using a batch file since I wanted to keep the whole thing clean with only a single script to process it. Each new file I have to add greatly (exponentially?) increases the chance that someone else who has to maintain it in the future will screw it up.

I'm disappointed that KiX apparently does not give me the flexibility to do this. That makes KiX far less attractive to me for everyday usage when simple things like this that I feel should be easy to handle from any scripting language simply aren't possible.

Looks like I'll be rewriting the whole thing in Perl, which I'd hoped to avoid. Sigh.

Again, thanks for the responses.

-- Jeff
-- aka The Eternal Newbie
_________________________

Top
#112991 - 2004-02-06 11:36 PM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, I might need to ask why this proggies needs to be that silly?
next, you can work around these issues you have with many ways.
one being kixcrypt.
you can also use any SFX capable packaging software to produce exe that allows the switches... etc.
_________________________
!

download KiXnet

Top
#112992 - 2004-02-06 11:38 PM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, btw.
simple commandline from the proggie could be yet easier.
if you can't control it, you can fake it.
let it think it's passing it's params to some proggie/script but instead filter them to file, etc.

ja, lot of choises there.
_________________________
!

download KiXnet

Top
#112993 - 2004-02-06 11:57 PM Re: Ordinary command line parameters
beerslayer Offline
Fresh Scripter

Registered: 2003-12-10
Posts: 15
Quote:

so, I might need to ask why this proggies needs to be that silly?



I wish I knew. It was not very cleverly written, but as I said in my original post, I do not have access to the sources and I do not feel like rewriting it from scratch.

Quote:

next, you can work around these issues you have with many ways.
one being kixcrypt.



I'm not familiar with kixcrypt. What does it do, and where can I find out more about it?

Quote:

you can also use any SFX capable packaging software to produce exe that allows the switches... etc.



This sounds like more trouble than it's worth. I can simply use Perl to do what I had hoped to do with KiX.

-- Jeff
-- aka The Eternal Newbie
_________________________

Top
#112994 - 2004-02-07 12:03 AM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh...
no, no trouble.
using something like winrar you can build control over both, the proggie and kixtart and script and ...
and all just about minute or two.

want to ask you about this soft though...
what are the commandline stuff you need to use?
can't you pipe it's output?

kixcrypt is ment for crypting kixtart scripts but I do use it to transfer installations and stuff.
you can include in the exe about everything you want.

_________________________
!

download KiXnet

Top
#112995 - 2004-02-07 01:47 AM Re: Ordinary command line parameters
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Looks like I'll be rewriting the whole thing in Perl, which I'd hoped to avoid. Sigh.



I guess it is your prerogative. Seems drastic for something that could be done in a one-line BATch file. Looks to me it is cutting your nose off to spite your face.
You seem to have a genuine dislike for KiX, judging by your comments here and your other thread on Break On. I wish you the best of luck in your Perl coding.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112996 - 2004-02-07 03:03 AM Re: Ordinary command line parameters
beerslayer Offline
Fresh Scripter

Registered: 2003-12-10
Posts: 15
Quote:

You seem to have a genuine dislike for KiX, judging by your comments here and your other thread on Break On. I wish you the best of luck in your Perl coding.



Not true. I don't dislike KiX. But I don't have any particular loyalty to it, either. It's just another tool in my tool chest, to be used for tasks for which it is the best suited tool. I am a bit disappointed at what seem to me to be fairly obvious shortcomings, and I expressed that disappointment.

I thought it was the best tool in this case. It turned out I was wrong. I don't want to rewrite everything in Perl, but KiX simply doesn't meet my needs. This does not mean that I won't use it in the future, just that it is not the best tool for this instance.

Hope that clarifies things,

-- Jeff
-- aka The Eternal Newbie
_________________________

Top
#112997 - 2004-02-07 03:19 AM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
there might be 2 things you could do.
1) post this in suggestions
2) email ruud (mail addy in manual) about this

both are used things and no change has happened in this matter.
but we might get our thoughts heard if we keep talking to him about them.
_________________________
!

download KiXnet

Top
#112998 - 2004-02-07 03:15 PM Re: Ordinary command line parameters
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I'm surprised that not using a one-line bacth file to launch the KiXtart script is actually worth a couple of hours of writing/testing/debugging another script.

You could always try passing an empty var as a "command-line switch", e.g.
Code:

kix32 script.kix $a $b


However, how would you differentiate between command-line switches intended for the KiXtart executable and command-line swithces intended for the script (which is also passed as a parameter)?
E.g.
Code:

kix32 script.kix /f
kix32 /f script.kix


Does the /f switch apply to the KiXtart executable or the script.kix script? There are ways around this, however, I don't think it's that important as you have ways to provide information from the command-line to the script.


Edited by sealeopard (2004-02-07 04:09 PM)
_________________________
There are two types of vessels, submarines and targets.

Top
#112999 - 2004-02-07 09:20 PM Re: Ordinary command line parameters
beerslayer Offline
Fresh Scripter

Registered: 2003-12-10
Posts: 15
Quote:

I'm surprised that not using a one-line bacth file to launch the KiXtart script is actually worth a couple of hours of writing/testing/debugging another script.


I've already explained this. I needed my "solution" to be all-in-one... one file that does everything. I cannot expect future users to remember to shuffle multiple files around - and - let's be honest - a solution involving multiple scripts (a batch and a KiX script) just isn't elegant.

Besides, it's done. It wasn't a couple of hours, it was about 10 minutes. I've spent more time discussing it on this forum than it took to actually write the Perl script...

Quote:

You could always try passing an empty var as a "command-line switch", e.g.
Code:

kix32 script.kix $a $b




Thanks, but this wouldn't have helped. I need to pass a file name, not just a switch.

Thanks to all who replied,

-- Jeff
-- aka The Eternal Newbie
_________________________

Top
#113000 - 2004-02-07 09:32 PM Re: Ordinary command line parameters
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
now you then have your proggie and the perl file to through around.
you being so cryptic in your words that no wonder we can't understand.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 809 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.072 seconds in which 0.025 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