Page 1 of 1 1
Topic Options
#180707 - 2007-09-18 10:44 PM Improved "Include" functionality.
MarcInCa Offline
Fresh Scripter

Registered: 2007-06-05
Posts: 22
Loc: Montreal, Canada
It would cool to have the ability to decide if the inclusion should take place or not for the INCLUDE statement during the pre-processing.

what I mean is to have some new functionality where we can decide if we need to "INCLUDE" files or not.

Example:

#IFNDEF $GLOBAL_DEFINE
#DEF $GLOBAL_DEFINE
INCLUDE "Inc\header\Script1.kix"

INCLUDE "Inc\header\Script1.kix"
#ENDDEF

The #DEF, #IFNDEF and #ENDDEF would be used by the kixtart to see if it needs to include or not the include files.
_________________________
Treat people the way you want to be treated.

Top
#180718 - 2007-09-19 09:22 AM Re: Improved "Include" functionality. [Re: MarcInCa]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Tricky.

Because INCLUDE is processed during the parse phase variables do not have values and are not evaluated. This is the reason that you cannot use variables in the INCLUDE path.

For a conditional include you should be using CALL - if you are concerned about the overhead overhead of repeated CALLs there are a couple of techniques that you can use to keep the code local.

You only need to use INCLUDE if you intend to create a monolithic tokenised script.

Do you have a specific example in mind where you cannot use CALL?

 Code:
If Not IsDeclared($GLOBAL_DEFINE)
   Call @SCRIPTDIR+"\Inc\Header\Globals.h"
EndIf

Top
#180720 - 2007-09-19 10:58 AM Re: Improved "Include" functionality. [Re: Richard H.]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
simple.
you have multiple scriptlets that all have requirements and thus have include line in them.

now, when you create your huge application based on kixtart that uses those scriptlets, you currently need to remove all the include lines from all the files and add them to the main file. either main script or main library.
anyhow, lots of work for that sorta approach.
_________________________
!

download KiXnet

Top
#180756 - 2007-09-20 10:34 AM Re: Improved "Include" functionality. [Re: Lonkero]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Quote:
now, when you create your huge application based on kixtart that uses those scriptlets, you currently need to remove all the include lines from all the files and add them to the main file


No you don't - I've been using conditional CALLs as a replacement for #IFDEF / #INCLUDE in main and sub-scripts ever since we got IsDeclared().

It is only a problem if you are going to tokenise the main file and the included scriptlets, otherwise the combination of CALL and IsDeclared() will do the job just as well.

In fact CALL is the generally going to be the better option, as you can use variables and macros in the path which can only be determined at run time.

The only other reason that I can think that you need include is if you want to declare local variables that you are then going to use in the main script. Not a good idea IMO.

Top
#180763 - 2007-09-20 05:52 PM Re: Improved "Include" functionality. [Re: Richard H.]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so add tokenization to my definition of the issue.
_________________________
!

download KiXnet

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 603 anonymous users online.
Newest Members
min_seow, Audio, Hoschi, Comet, rrosell
17881 Registered Users

Generated in 0.052 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org