Page 1 of 1 1
Topic Options
#17887 - 2002-02-24 04:58 PM Passing variables to scripts or function with gosub
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
Hi,

Is it possible to pass variables on to scripts or subroutines in kix.

E.g.: if I have a script, such as 'dircompare.kix' on the wanadoo website and I have a number of directories I want to compare, can I call the script and pass it the directories to work with.

It would envisage the script looking somthing like this:

<<<
call script name varable1 varable2
>>>

The two variables would get picked up by the called script , and in the case of the one above take varable1 as the source directory and v2 as the destination.

Is this beyond the capabilities of kix?

bye

Darren

[ 24 February 2002: Message edited by: Darren Whittington ]

[ 24 February 2002: Message edited by: Darren Whittington ]

[ 24 February 2002: Message edited by: Darren Whittington ]

_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
#17888 - 2002-02-24 05:28 PM Re: Passing variables to scripts or function with gosub
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You need not pass variables as parameters as in your example. Variables are available as per the rules described in the manual. This can very easily be tested with just a few lines of code. Take note of DIM and GLOBAL as well.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#17889 - 2002-02-24 05:41 PM Re: Passing variables to scripts or function with gosub
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
Hi,

Not meaning to be stupid.

Can I assume that using somthing like this would work then?

;Specify two varables

$GlobalSource = "j:\desktop"
$GlobalDestination =ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Desktop")
IF (Substr($dir1,Len($dir1),1) <> '\')
$GlobalDestination=GlobalDestination+"\" ; - destination directory -
ENDIF
;Call Script

Call "dircompare.kix"

{repeat for other directories}

etc, etc...

With the called script using $GlobalSource and destination as the directories..

Darren

_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
#17890 - 2002-02-24 05:51 PM Re: Passing variables to scripts or function with gosub
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... I'm not going to use your example as it is incomplete, but will write a little test to explain. There are two scripts, test.txt calls test2.txt.
code:

;test.txt
break on

$GlobalDestination =ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Desktop")

Call "C:\KiX4.02\test2.txt"



code:

;test2.txt
break on
$GlobalDestination ?
"hit any key" ?
get $_

Like I said, a quick little test will enlighten.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.084 seconds in which 0.067 seconds were spent on a total of 12 queries. Zlib compression enabled.

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