#134488 - 2005-02-24 04:09 PM
Call a sub
|
alexchevrier
Fresh Scripter
Registered: 2002-11-11
Posts: 15
Loc: Quebec
|
Moderators note: Thread moved to General Discussions. Original author may resubmit the suggestion, if after discussion, it is still desired.
I suggest a command to call a sub in a different file. I use many kix files on different domains, but often sub-routines are identical and I must modify them in every files when I change something.
With a file containning all the subs, I would just have to copy this file on every domains instead of modifying it on every domains.
Edited by Les (2005-02-24 08:07 PM)
|
|
Top
|
|
|
|
#134490 - 2005-02-24 06:43 PM
Re: Call a sub
|
alexchevrier
Fresh Scripter
Registered: 2002-11-11
Posts: 15
Loc: Quebec
|
What is UDF ?
|
|
Top
|
|
|
|
#134492 - 2005-02-24 07:24 PM
Re: Call a sub
|
alexchevrier
Fresh Scripter
Registered: 2002-11-11
Posts: 15
Loc: Quebec
|
All I see in the manual is the Function... and it doesn't seem to be able to do what I want to, which is regroup all my subs (or functions) in a single file so that when I modify one sub, I can simply copy it in every netlogon folder instead of modifying every files.
I'll give an exemple... Let's say a create a file called subs-funtions.kix, which contains sub1 and sub2. From my main kix file, I would like to be able to do something like this : call "subs-functions.kix, sub1".
Is UDF able to do that ?
|
|
Top
|
|
|
|
#134494 - 2005-02-24 07:40 PM
Re: Call a sub
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
les: move this thread to general please.
alexchevrier:
here is an example.
using gosubs... what you have now with everythign in one file. Code:
? "starting a GOSUB now!" gosub "sub1" ? "THE Gosub is finished."
exit 0
:sub1 ? "the SUB1 is now running" return
now here is an example of using UDF's (User Defined Function)
this is your main script Code:
call 'functions.kix'
? "starting Function1" Function1 ? "Function1 is finished"
and here is Functions.kix
Code:
Function Function1 ? "Running Function1!" endfunction
Function Function2 ? "Running Function2!" endfunction
|
|
Top
|
|
|
|
#134495 - 2005-02-25 11:12 AM
Re: Call a sub
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
I'll give an exemple... Let's say a create a file called subs-funtions.kix, which contains sub1 and sub2. From my main kix file, I would like to be able to do something like this : call "subs-functions.kix, sub1".
Is UDF able to do that ?
Yes, it is - in fact it is superior to the method that you are suggesting.
Convert all your sub-routines to UDFs using Function/EndFunction and store in your file "subs-functions.kix"
At the start of your script, "CALL subs-functions.kix". This won't execute any code, but it will load your functions into memory ready to be executed when needed.
Now in your script you can call sub1() sub2() whenever you like because they have been loaded in memory - you don't need to call the "subs-functions.kix" file again.
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 685 anonymous users online.
|
|
|