Kdyer
(KiX Supporter)
2005-04-08 10:32 PM
2010 Beta 2a - Couple of issues

(1) Trying to understand or get the include working:

In our script today, we have:
Code:

IF RIGHT(@SCRIPTNAME,2)='kx'
CALL @ldrive+'kldtest\function.kx'
ELSE
CALL @ldrive+'kldtest\function.kix'
ENDIF


CALL works fine.

Why can't I do the following?
Code:

IF RIGHT(@SCRIPTNAME,2)='kx'
INCLUDE @ldrive+'kldtest\function.kx'
ELSE
INCLUDE @ldrive+'kldtest\function.kix'
ENDIF



(2) Not sure of the search path of W/KIX32, but when I run:
C:\Scripts>kix32 %logonserver%\netlogon\kldtest\kixtart

The script works fine.

But, when I run:
C:\Scripts>kix32 %logonserver%\netlogon\kldtest\kixtart.KIX

The script comes back with the following message:
Quote:


ERROR : expected string!
Script: \\CHIRON\netlogon\kldtest\kixtart.KIX





So, I am assuming that W/KIX32 automatically picks up on the .KX or compiled script before the .KIX or text version?

How this came about is that I am playing with the script, but have one that is tokenized there. So, I get bad results unless I specify the .kix extension. Call me lazy.

Thanks,

Kent


LonkeroAdministrator
(KiX Master Guru)
2005-04-08 10:46 PM
Re: 2010 Beta 2a - Couple of issues

include is an include option.
it includes the told script(s) to the including one, before any processing.
if you wanna call - or in other words, include at run time - a script, use call.

what comes to the .kix... well, worked for me on local drive...


Kdyer
(KiX Supporter)
2005-04-08 10:49 PM
Re: 2010 Beta 2a - Couple of issues

Right.. But what I want to do is to INCLUDE the function script that used by several different companies in our main login script and the problem is that I have to CALL function.kix file again from one of the branch-outs from KiXtart.kix.

So, what you are saying is that you have to have a hard-mapped drive to run this correctly?

Kent


Kdyer
(KiX Supporter)
2005-04-08 10:57 PM
Re: 2010 Beta 2a - Couple of issues

Did some more playing with this..

Commented out:
Code:

$rc=SETOPTION('Explicit','On')
$rc=SETOPTION('NoVarsInStrings','On')



And did some changes to my code - Yes I know Vars in Strings are evil.

Code:

; -- LOAD FUNCTIONS
IF RIGHT(@SCRIPTNAME,2)='kx'
INCLUDE '@ldrive\kldtest\function.kx'
ELSE
INCLUDE '@ldrive\kldtest\function.kix'
ENDIF



And.. Get an intersting error:
Quote:


ERROR : failed to find/open script [@ldrive\kldtest\function.kx]!
Script: kixtart.kix



The function.kx is there and is updated with the new version of KiX.

I map my DC\Netlogon as a drive, it works fine:
Code:

IF RIGHT(@SCRIPTNAME,2)='kx'
INCLUDE 'z:\kldtest\function.kx'
ELSE
INCLUDE 'z:\kldtest\function.kix'
ENDIF



Thanks,

Kent

Sealeopard
(KiX Master)
2005-04-09 01:08 AM
Re: 2010 Beta 2a - Couple of issues

IIRC, Ruud has stated multiple times that macros and variables cannot be used in the INCLUDE function, otherwise the pre-tokenization would not work if the final INCLUDE path is only being decided upon at run-time. Then again, doing an INCLUDE at run-time is kind-of pointless, anyway.

LonkeroAdministrator
(KiX Master Guru)
2005-04-09 09:14 AM
Re: 2010 Beta 2a - Couple of issues

and, if one wants it, there is call that does exactly that.

Ruud van Velsen
(Hey THIS is FUN)
2005-04-11 03:43 AM
Re: 2010 Beta 2a - Couple of issues

The issue here is that the current implementation of INCLUDE only accepts clear-text scripts (ie: .KIX scripts, not .KX scripts). Sorry this wasn't clear yet, I'll make sure it is clarified in the documentation.

Kind regards,

Ruud


Les
(KiX Master)
2005-04-11 03:50 AM
Re: 2010 Beta 2a - Couple of issues

Ruud,
What about the macro and UNC in the path? Any comment?


LonkeroAdministrator
(KiX Master Guru)
2005-04-11 12:32 PM
Re: 2010 Beta 2a - Couple of issues

and the path...
not relative to curdir but exe-dir.


Ruud van Velsen
(Hey THIS is FUN)
2005-04-12 07:52 PM
Re: 2010 Beta 2a - Couple of issues

In short: INCLUDE takes either an absolute path (including a drive or UNC reference) or a path relative to the current directory.

Using macros, vars or functions with an INCLUDE statement is not supported and does not make a lot of sense (at least not considering the way it was designed). All INCLUDE does is 'tack' the INCLUDed script into the INCLUDing script. The result is just as if you had typed the INCLUDed script in the INCLUDing script. After the INCLUDE is processed and the resulting script as been tokenized, the INCLUDE statement itself is effectively gone.

What this does is provide a way to write small, modular, re-usable 'script-lets' and at the same time produce a single KX-script for use in production.

If you need to be able to dynamically call different scripts based on runtime information, you really need the CALL statement.

Let me know if there any additional questions or suggestions.

Regards,

Ruud


LonkeroAdministrator
(KiX Master Guru)
2005-04-13 10:08 AM
Re: 2010 Beta 2a - Couple of issues

yes.
this is the info from start to finish.
and even looks clean and mean enough for manual

thanks ruud.