Page 1 of 1 1
Topic Options
#41881 - 2003-06-20 04:57 PM UDF and Function Question
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
Can you have a function within a function or should I create a separate script with the UDF code in it and call the UDF from within my main script ?

Grasshopper75

Top
#41882 - 2003-06-20 05:01 PM Re: UDF and Function Question
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
You cant have functions within functions, but whether or not you can have the UDF in your main script or in a library is another question. You can include the UDF into your main script (say, at the bottom) or put it into a seperate script (for example lib.kix), then "call" it from your main script (at top of script) example:

Break On

Call "lib.kix"

...your stuff

Once you have called it, you can use any of the functions in the rest of the script body, just as if you had included it in main.

-Shawn

[ 20. June 2003, 17:03: Message edited by: Shawn ]

Top
#41883 - 2003-06-20 05:06 PM Re: UDF and Function Question
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
I'm trying to figure out the ArrayEnumKey() UDF and don't quite understand what I need to do with it.

I'm trying to enumerate all the NIC cards in the reg key HKLM\System\CurrentControlSet\Services\NetBT\Adapters\

Grasshopper75

Top
#41884 - 2003-06-20 05:08 PM Re: UDF and Function Question
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Wouldn't you need to do something like a comparison?

That is -
code:
if $currentsubkey = "value"
;do something
else
;do something else
endif

Kent

[ 20. June 2003, 17:10: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#41885 - 2003-06-20 05:09 PM Re: UDF and Function Question
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also the FAQ Forum under How to use UDFs and How to write a UDF .

You can actually, have a "function within a function", demonstrated in Err() - Prints an error message on screen and writes the error into the error log which dynamically creates a new UDF via an EXECUTE() statement and then calls that UDF.
_________________________
There are two types of vessels, submarines and targets.

Top
#41886 - 2003-06-20 05:11 PM Re: UDF and Function Question
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why don't you give the example in the UDF header a try? Alternatively, try
code:
;fixed code
$array=arrayenumkey('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\NetBT\Adapters')
for each $nic in $array
? 'NIC = '+$nic
next



[ 22. June 2003, 22:33: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#41887 - 2003-06-20 05:16 PM Re: UDF and Function Question
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
I need to enumerate all the subkeys and then write a value to each subkey to clear WINS entries.

The subkeys are different on each machine and some machines have multiple subkeys which is why I need to use the ArrayEnumKey UDF.

Top
#41888 - 2003-06-20 05:21 PM Re: UDF and Function Question
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And you point is? [Confused]

Did you even give my code example a try?
_________________________
There are two types of vessels, submarines and targets.

Top
#41889 - 2003-06-20 05:25 PM Re: UDF and Function Question
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
Sorry sealeopard, I was writing the post as you posted your reply. Thanks, I will give it a go.
Top
#41890 - 2003-06-20 06:47 PM Re: UDF and Function Question
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
Thanks everyone, I have now got it working [Smile]

Cheers,
Grasshopper75

Top
#41891 - 2003-06-21 03:49 AM Re: UDF and Function Question
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I tried your code Jens... but it did not work.

Was missing the ) on the end of the line. [Big Grin]

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.176 seconds in which 0.076 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