Page 1 of 1 1
Topic Options
#131836 - 2004-12-29 07:44 PM Pass-Through for Function calls
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
If I am missing something, please let me know..

We use functions and incorporate them usually in one file..

I got to thinking about this and why can we not have the executable pass through the function and parameters? For example:

KIX32 YOURFUNCTIONS.KIX /Function:MyCustomFunction(parameter1)

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#131837 - 2004-12-29 10:18 PM Re: Pass-Through for Function calls
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
So your suggesting that kix32 would first "load" the script YOURFUNCTIONS.KIX, than it would automatically call "MyCustomFunction" with your passed params, and then exit normally, is that the idea ? Kinda like calling a function from the command line ?
Top
#131838 - 2004-12-29 10:34 PM Re: Pass-Through for Function calls
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Correct..

I don't know if we need to load the whole file first, but rather call the function from the command-line.

Probably like you, I have a lot of little scripts that I use and if I need to setup something like an application or a printer, why not be able to call it like you do as a function call, but rather from the command line, a batch file, or Scheduled Task?

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#131839 - 2004-12-29 10:39 PM Re: Pass-Through for Function calls
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I know this solution would not be part of kix32, but the kixstart.bat script I wrote could easily be modified for the functionality you are asking for. If you are interested, let me know. This is not a bad idea, and who knows, I might add it even if you are not interested in using it.
Top
#131840 - 2004-12-30 04:07 AM Re: Pass-Through for Function calls
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Allen,

Please, it's KiXtart not KixStart.

Top
#131841 - 2004-12-30 08:11 AM Re: Pass-Through for Function calls
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
to be honest, I don't see reason for this commandline extension.
if you wanna have some function executed, you might as well name kixtart after it.
so instead of kix32.exe (I know you are old school) it would be myDirtyFunction.exe and scriptname kixtart.kix

anyways, I don't see a point exploiting the commandline so much.
if you have a special need, please tell us.
dunno if just "don't wanna go with $var=blaah pass, wanna have something more special" qualifies though
_________________________
!

download KiXnet

Top
#131842 - 2004-12-30 03:22 PM Re: Pass-Through for Function calls
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Chris,
LOL! Thanks for the spellcheck. I had no idea.

Jooel,
Well since I've heard nothing from Kent, I may not mess with it. TBH, I have no real use for it either, other than just an slight interest and entertainment of figuring it out.

Top
#131843 - 2004-12-30 08:34 PM Re: Pass-Through for Function calls
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Al,

I started to look at your Batch Script and was not successful.. If it is a simple matter of changing the Bat file, then cool.

Jooel - This may not be needed to be added to the base W/KiX32.EXE as Al maybe able to whip something up.

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#131844 - 2004-12-30 08:57 PM Re: Pass-Through for Function calls
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kent, indeed that was my point.
_________________________
!

download KiXnet

Top
#131845 - 2004-12-30 09:02 PM Re: Pass-Through for Function calls
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Kent... yes its just a matter of adding a line or two... I'll work on it this evening and post it later.
Top
#131846 - 2004-12-30 09:08 PM Re: Pass-Through for Function calls
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, I understand the bat but I don't see a reason for the direct UDF calling stuff still.
can't see no reasoning whatsoever.
kent, could you explain what you are after?
_________________________
!

download KiXnet

Top
#131847 - 2004-12-30 10:50 PM Re: Pass-Through for Function calls
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Needed or not... here is the new version
Kixstart.bat 1.2

Top
#131848 - 2004-12-30 11:36 PM Re: Pass-Through for Function calls
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Sweet! Thanks for the update.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#131849 - 2005-01-05 10:03 AM Re: Pass-Through for Function calls
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
No need for built-ins, you can add this functionality very easily to you own libraries.

The UDF library below shows the simplest method, with no parameter checking.

It is very easy to add code to parse the file and perform parameter checking, and/or automatic help text if the function is called incorrectly.

As an example, if you save this script as "demolib.udf" you can include it in a main script as you normally would, or call the functions directly from the command line using someingthing like:
Code:
kix32 demolib.kix $__UDF="udfGreeting" $__P1="Good morning" $__P2="Richard"



Because there is no parameter checking, if you specify too many or too few parameters KiXtart will fail with not very helpful error messages.

The only other caveat of course is that if you have a global variable $__UDF defined in you main script when you call the library it will attempt to call the UDF. You can also protect against this, but it is pretty unlikely to occur.

Code:
; UDF library calling demo.

; This sample script shows how to write a KiXtart library to allow functions to be called
; arbitrarily from the command line as well as from scripts.

; This is the simplest version, with no parameter checking or help

Function udfDemo()
"Called function udfDemo_1 OK" ?
Exit 0
EndFunction

Function udfGreeting($sTimeOfDay,$sUserName)
$sTimeOfDay+" "+$sUserName+", welcome to the ACME network."+@CRLF
Exit 0
EndFunction

;---------------------------------------------------------------------------------------------
; Stand-alone function call.
; This code is executed when the library is called with $__UDF set.
; This is intended to allow the library functions to be called directly
; from the command line.
If IsDeclared($__UDF)
BREAK ON
$=SetOption("Explicit","ON")
Dim $iParamIndex,$sParams,$sQuote
$sQuote='"'
$iParamIndex=1
While Execute("Exit IsDeclared($$__P"+$iParamIndex+")")
$=Execute("$$sParams=$$sParams+','+$$sQuote+$$__P"+$iParamIndex+"+$$sQuote")
$iParamIndex=$iParamIndex+1
Loop
Exit Execute($__UDF+"("+SubStr($sParams,2)+")")
EndIf

; vim600: filetype=kix ts=4 sw=4 ai fdc=4 fdm=marker


Top
#131850 - 2005-01-06 04:02 AM Re: Pass-Through for Function calls
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Richard,

This is interesting.. Looks like I am going to have to go play. This is also covered on page 21 of the guide too.

Thanks for the insights.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.066 seconds in which 0.044 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