Page 1 of 1 1
Topic Options
#209371 - 2014-08-07 04:13 PM @scriptdir wrong on include?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
@scriptdir points to location of included scripts, not the actual script.

does anybody else think this is incorrect behavior?
_________________________
!

download KiXnet

Top
#209379 - 2014-08-07 09:03 PM Re: @scriptdir wrong on include? [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
I would not have expected that, but it does kind of make sense. It appears to reference that last loaded script.

What version are you testing? I can't replicate this with
 Code:
Break On

'Kix version ' @KIX ?

'ScriptDir / CurDir' ?
@SCRIPTDIR ' / ' @CURDIR ?
'Call' ?
Call 'C:\Temp\tst\x1.txt'
@SCRIPTDIR ' / ' @CURDIR ?
'Include' ?
Include 'C:\Temp\tst\x2.txt'
@SCRIPTDIR ' / ' @CURDIR ?
It always reports the same path

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

Top
#209390 - 2014-08-08 06:07 AM Re: @scriptdir wrong on include? [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
4.53
_________________________
!

download KiXnet

Top
#209391 - 2014-08-08 06:08 AM Re: @scriptdir wrong on include? [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
And include isn't really loading a script. It is embedding another source piece into the script.
_________________________
!

download KiXnet

Top
#209393 - 2014-08-08 04:08 PM Re: @scriptdir wrong on include? [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Sure - it's loading a file.. I'm thinking that it's being treated as a script and the last loaded include updates the ScriptDir macro. What it does and how it thinks its working may be two (or more) different things entirely.

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

Top
#209395 - 2014-08-08 04:35 PM Re: @scriptdir wrong on include? [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
As I have never understood the purpose of include, I have no idea what is right.
_________________________
(... better days ahead)

Top
#209397 - 2014-08-08 04:46 PM Re: @scriptdir wrong on include? [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Allen, include is pre-execution inclusion of a script.

a call calls during execution. with include kixtart injects the included script in to the main script in where ever the include statement is located. and once the combining has been completed and execution starts, kixtart has no idea that the code was made of more than one file.

that's the theory. clearly it does not work right if the result of include is mangled macro's etc.
_________________________
!

download KiXnet

Top
#209398 - 2014-08-08 04:59 PM Re: @scriptdir wrong on include? [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
.... honestly, where is this useful? I so rarely CALL either, but when I do it usually to call a library of UDFs. As far as I can tell from that point forward kixtart has no idea where they come from either.
_________________________
(... better days ahead)

Top
#209399 - 2014-08-08 05:14 PM Re: @scriptdir wrong on include? [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the difference is, call can be done at any point during execution. multiple times.

say you have a broken UDF definition in a script file. with call you can call it when needed. after your script has done lot of other stuff.
since the UDF definition is faulty, kixtart will crash.

with include, the UDF is inspected just as if it was part of the main script.

in same way, multiple definition of same var names, same udf names, basically anything that causes grief can be greatly mitigated by using include.

what it boils down to is include is static and call is dynamic. include is done once, call happens during execution as many times as the scripter wishes.

I do have a programming background and I do love the include. well, would do if it worked right. but once it got introduced, I have not used call like ever since.
_________________________
!

download KiXnet

Top
#209400 - 2014-08-08 06:31 PM Re: @scriptdir wrong on include? [Re: Lonkero]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
What makes it even more strange, is that according to the manual, macros should not even be available during the include portion...because of it occuring in pre-execution. So I don't know how it could be changing the value of the macro. @ScriptDir isn't a cached value is it that is still from the previously run script, until execution starts? I wouldn't think so, but just a thought.

Also, I ran Glenn's test script above and my macros remained pointing to the script location. Never changed to the include directory.

 Quote:
Note that INCLUDE statements are processed during the pre-processing phase of KiXtart at which point macros, variables and functions are not yet available. As such, INCLUDE only supports a single, flat string and you can not use macros, variables or functions in it.

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
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.068 seconds in which 0.033 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