Page 1 of 1 1
Topic Options
#180680 - 2007-09-18 05:37 PM Problem with Include when using call other Kix Scripts.
MarcInCa Offline
Fresh Scripter

Registered: 2007-06-05
Posts: 22
Loc: Montreal, Canada
Hello every one,

Here is my problem. I have written small self contain kixtart script which work well. In which each script, I do use the "Include" statement to include small kixtart functions I wrote.

Now i need to write a parent script which call the small self contain kixtart scripts.

The problem is when I run the main script, I get an "Error: Doubly defined UDF" when it "calls" the second script in the main script.
I presume it is because the second script tries to "include" the "Include" statement. But they were already loaded by the first script.

I need to keep the self contain kitart script but I need a way to let it know that if the "Include" files are already loaded It should not try to reload the existing "Include".

You help will be appreciated. thanks every one !
_________________________
Treat people the way you want to be treated.

Top
#180681 - 2007-09-18 05:55 PM Re: Problem with Include when using call other Kix Scripts. [Re: MarcInCa]
MarcInCa Offline
Fresh Scripter

Registered: 2007-06-05
Posts: 22
Loc: Montreal, Canada
Here is more informations:

Main.kix:
CALL "Script1.kix"
CALL "Script2.kix"


Script1.kix:
INCLUDE "Include\InstallSoft.kix"
InstallSoft("d:\Software\Program1\setup.exe")


Script2.kix:
INCLUDE "Include\InstallSoft.kix"
InstallSoft("d:\Software\Program2\toto.exe")
_________________________
Treat people the way you want to be treated.

Top
#180684 - 2007-09-18 06:45 PM Re: Problem with Include when using call other Kix Scripts. [Re: MarcInCa]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Yep, it is the second call that errors out
Maybe you want to include your InstallSoft.kix in your Main.kix

Top
#180687 - 2007-09-18 06:59 PM Re: Problem with Include when using call other Kix Scripts. [Re: Witto]
MarcInCa Offline
Fresh Scripter

Registered: 2007-06-05
Posts: 22
Loc: Montreal, Canada
Yup ! I know i could do that.
But then the concept of my self-contained smaller scripts would go down the tube and would need to rewrite them. The Script1 and Script2 already being used as is for other tasks as is and work great. I was hoping I could re-used their functionality "as is" within a great kixtart script without having to rewrite these "sub-scripts".

I presumed the scope of the INCLUDE statement were limited to within the script (Script1 and Script2) they are being called and not used "Globally" for the whole session (Main).

I was wondering if there was a way to use "If NOT Define C like statement", so we could test to see if the Include was already laoded or not. If it was not loaded, then the "include" would be loaded.

Thanks for the help, It is appreciated. Any one had similar problems like mine and have found a solution or work around ?



Edited by MarcInCa (2007-09-18 07:04 PM)
_________________________
Treat people the way you want to be treated.

Top
#180689 - 2007-09-18 08:04 PM Re: Problem with Include when using call other Kix Scripts. [Re: MarcInCa]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
I moved away from run-time UDF inclusions for this, among other reasons.

My KGen utility will parse your script source, identify external UDFs, and include them from one or more library folders into a single script. It resolves dependencies, so one UDF can call another, and both will be in your final script. Further, it assures that UDFs are only loaded once. (Not to mention the built-in Sanity feature that identifies many programmatic errors before you run your code!)

You can get this in the KixDev package from my web site.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#180691 - 2007-09-18 08:17 PM Re: Problem with Include when using call other Kix Scripts. [Re: Glenn Barnas]
MarcInCa Offline
Fresh Scripter

Registered: 2007-06-05
Posts: 22
Loc: Montreal, Canada
Thank you Glenn ! For the information. I will take a look at you KGen if need be. I am currenttly looking at some possible changes in my code so i wont need to re-rewrite much of the functionality.

One ideas came up of creating the main files using bits of the code foudn in the smaller script. This may mean soem doubling of sources but its minor compare to tryign to make work what I have now.

I taught the "scope" of the include was only be a "File" based and not a "session". Guess it is the opposite. Well at least, I learn a new limit on kixtart. \:\)
_________________________
Treat people the way you want to be treated.

Top
#180692 - 2007-09-18 08:20 PM Re: Problem with Include when using call other Kix Scripts. [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Glenn's KGEN method is actually quite cool (not easy to grasp how to use it at first but once you get it going it's a good way to go)
Top
#180693 - 2007-09-18 09:10 PM Re: Problem with Include when using call other Kix Scripts. [Re: NTDOC]
MarcInCa Offline
Fresh Scripter

Registered: 2007-06-05
Posts: 22
Loc: Montreal, Canada
Well Every one ! By reading this thread (and fresh coffee), an idea did come into my head. Since my Script1 and Script are self contains apps that work well, Why not call them as if they were seperate apps in the main programs.

Instead of :
Main.kix:
CALL "Script1.kix"
CALL "Script2.kix"

Script1.kix:
INCLUDE "Include\InstallSoft.kix"
InstallSoft("d:\Software\Program1\setup.exe")

Script2.kix:
INCLUDE "Include\InstallSoft.kix"
InstallSoft("d:\Software\Program2\toto.exe")

We can do:
Main.kix:
SHELL "wkix32 Script1.kix"
SHELL "wkix32 Script2.kix"

Script1.kix:
INCLUDE "Include\InstallSoft.kix"
InstallSoft("d:\Software\Program1\setup.exe")

Script2.kix:
INCLUDE "Include\InstallSoft.kix"
InstallSoft("d:\Software\Program2\toto.exe")

It works well. Since they are called by the SHELL function they are run as seperate entities and no problem with the "include".

Now i dont need to change my scripts that were "self-contained" and I get to call them up in a Main kix start. and even can use the return code from the smaller scripts and use it in Main kixtart script.

Thank you every one for the help. It really helped in the brainstorming for a good comprise that works out great for me \:\)
_________________________
Treat people the way you want to be treated.

Top
#180694 - 2007-09-18 09:13 PM Re: Problem with Include when using call other Kix Scripts. [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh...
why would you want to mix call and include?

in my opinion, those are 100% exclusive methods...

anyways, it's true that kixtart should have a pre-execution methods for inclusion of stuff... like the compiler commands seen in other languages.
_________________________
!

download KiXnet

Top
#180696 - 2007-09-18 09:31 PM Re: Problem with Include when using call other Kix Scripts. [Re: Lonkero]
MarcInCa Offline
Fresh Scripter

Registered: 2007-06-05
Posts: 22
Loc: Montreal, Canada
I agree Jooel !

It would be nice if the next generation of kixtart could have a pre-execution methods for inclusion of files / functions... like in compiler commands seen in other languages.

I will see if there is a suggestion box and slip that idea in the suggestion box ;\)
_________________________
Treat people the way you want to be treated.

Top
#180703 - 2007-09-18 10:02 PM Re: Problem with Include when using call other Kix Scripts. [Re: MarcInCa]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
we have the method of inclusion, just to note.
what we lack is the ability to decide if the inclusion should take place or not.
_________________________
!

download KiXnet

Top
#180706 - 2007-09-18 10:29 PM Re: Problem with Include when using call other Kix Scripts. [Re: Lonkero]
MarcInCa Offline
Fresh Scripter

Registered: 2007-06-05
Posts: 22
Loc: Montreal, Canada
Yup ! I meant about the ability to decide if the inclusion should take place or not.
_________________________
Treat people the way you want to be treated.

Top
#180708 - 2007-09-18 11:32 PM Re: Problem with Include when using call other Kix Scripts. [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
 Originally Posted By: Jooel
eh...
anyways, it's true that kixtart should have a pre-execution methods for inclusion of stuff... like the compiler commands seen in other languages.

This is exactly what KGen is based on - a link-editor of sorts. Resolve all external dependencies and generate a finished script (or library).

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#180719 - 2007-09-19 09:28 AM Re: Problem with Include when using call other Kix Scripts. [Re: Glenn Barnas]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I'm not at all sure why you think that you have a problem.

Just wrap the CALLs in a conditional - see my anwer to your post in the suggestions forum.

You only need to worry about INCLUDE when creating a monolithic tokenised script. In (almost) all other circumstances you can get by with CALL.


Edited by Richard H. (2007-09-19 09:30 AM)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.069 seconds in which 0.027 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