#131836 - 2004-12-29 07:44 PM
Pass-Through for Function calls
|
Kdyer
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
|
Top
|
|
|
|
#131838 - 2004-12-29 10:34 PM
Re: Pass-Through for Function calls
|
Kdyer
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
|
Top
|
|
|
|
#131839 - 2004-12-29 10:39 PM
Re: Pass-Through for Function calls
|
Allen
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.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Allen,
Please, it's KiXtart not KixStart.
|
Top
|
|
|
|
#131842 - 2004-12-30 03:22 PM
Re: Pass-Through for Function calls
|
Allen
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
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
|
Top
|
|
|
|
#131847 - 2004-12-30 10:50 PM
Re: Pass-Through for Function calls
|
Allen
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
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Sweet! Thanks for the update.
Kent
|
Top
|
|
|
|
#131849 - 2005-01-05 10:03 AM
Re: Pass-Through for Function calls
|
Richard H.
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
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
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 1574 anonymous users online.
|
|
|