#134579 - 2005-02-25 07:09 PM
How the new INCLUDE statement works...
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
This is my take on how the new INCLUDE statement works in 4.50 ... works just like the CALL statement, except that if your tokenizing a script, it will "embed" or "include" these external scripts inside the generated KX (tokenized) script itself, by way of example:
1) Create a script called SUB.KIX that contains the following:
SUB.KIX
$X = 100
$Y = 200
2) Create a "mainline" script called MAIN.KIX that "uses" this external script, will use the CALL statement for this first example:
MAIN.KIX
break on
call "sub.kix"
?"x=" $X
?"y=" $Y
3) If you just run the mainline script, you would get this expected result:
C:\>kix32 main.kix
x=100
y=200
4) Now, change the CALL statement in MAIN, to be an INCLUDE statement, and run it again (the same result, INCLUDE is like a CALL):
MAIN.KIX
break on
include "sub.kix"
?"x=" $X
?"y=" $Y
C:\>kix32 main.kix
x=100
y=200
5) Now here is the neat part, tokenize MAIN.KIX into MAIN.KX, like this:
C:\>kix32 /t main.kix
6) Then run MAIN.KX and you get this:
C:\>kix32 main.kx
x=100
y=200
7) Now - the really cool part, delete (or rename away) the original SUB.KIX file, the MAIN tokenized script still works because SUB.KIX is "part of" (it's been included into), MAIN.KX, like this:
C:\> ren sub.kix sub.tmp
C:\> kix32 main.kx
x=100
y=200
If you ran the original (untokenized) MAIN.KIX again, it would fail, because SUB.KIX is not there !
Here's more, been doing much testing with using FUNCTION calls in INCLUDED scripts, and I am getting nasty Kixtart crashes - so think Ruud had some more work to do with functions in included files.
-Shawn
|
Top
|
|
|
|
#134591 - 2005-02-27 06:17 AM
Re: How the new INCLUDE statement works...
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
I am interested to see what INCLUDE does. CALL, I am seeing some behaviors where VARs are not be passed to CALLed scripts. I will have to test and see.
Kent
|
Top
|
|
|
|
#134593 - 2005-02-28 10:40 PM
Re: How the new INCLUDE statement works...
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Maybe I am a bit asleep here..
Did some testst with this: Code:
IF RIGHT(@SCRIPTNAME,2)='kx' INCLUDE @LDRIVE+'newscript\function.kx' ELSE INCLUDE @LDRIVE+'newscript\function.kix' ENDIF
Results:
Quote:
ERROR : expected string! Script: \\<DC>\netlogon\newscript\kent\kixtart.kix
If I change it to (I know VARS in strings are evil): Code:
IF RIGHT(@SCRIPTNAME,2)='kx' INCLUDE '@scriptdir\function.kx' ELSE INCLUDE '@scriptdir\function.kix' ENDIF
Results:
Quote:
ERROR : failed to find/open script ["]! Script: \\<DC>\netlogon\newscript\kent\kixtart.kix
Thanks,
Kent
|
Top
|
|
|
|
#134598 - 2005-03-10 09:42 AM
Re: How the new INCLUDE statement works...
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
This is an invitation to write new and/or publish an existing KiXtart script that is the equivalent of 'make'
Not at all.
"Make" is a generic project management tool, and handles KiXtart files perfectly well.
When Ruud first proposed the INCLUDE statement I posted details of how to use "make" to generate monolithic scripts suitable for tokenising. Can't find the blasted post now however.
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 369 anonymous users online.
|
|
|