Page 1 of 1 1
Topic Options
#75790 - 2003-07-10 09:08 AM UDF calls
didlyjack Offline
Fresh Scripter

Registered: 2003-07-09
Posts: 8
First, I know I'm a KiXdiot,

So now here's the question;
Must you put a 'call' statement to your UDF library in your script at the begining of every script that uses one (or more)
code:
 Call library.udf 

or will simply stating a function
ie:
code:
 Function scheduletask2()
; insert the function
EndFunction

somewhere in your script do the trick? And if so how/where do you save the UDF so that KiXtart will use it? I know that the 'call' works and understand why, but I see a lot of script that doesn't include a 'call' statement to the .UDF and I am confused. Is the 'call' just assumed? Or am I missing something from the "how to's", FAQ's and the manual? Please enlighten.

[ 10. July 2003, 09:16: Message edited by: didlyjack ]

Top
#75791 - 2003-07-10 09:22 AM Re: UDF calls
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the call can be used when you have the UDF in separate "UDF library file" (nice name [Wink] )

if you have a udf you don't want to call, like if you prefer it to be in the same kix-file, just add the function (everything beginning from function to endfunction) into your script.

there are many places where you can place it like above anything else.
most ppl prefer them at the end of the file.

basically, you can insert it anywhere (not inside loops [Wink] ) but that is your call.
just remember that UDFs are not executed automatically they are just readen from the script file when script loads the file...
_________________________
!

download KiXnet

Top
#75792 - 2003-07-10 09:24 AM Re: UDF calls
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
You only have to call the UDF(s) once in your scripts. If you have more than one script running seperately you'll have to include the call in every script. If you have a bunch of script calling each other, you'll only need to call the UDF(s) once.

You'll have to call the UDF(s) with path if it's in another dir.

-----------------------
Or just look at the comment of Lonkero...

[ 10. July 2003, 09:30: Message edited by: Schuliebug ]
_________________________
Kind regards,

Top
#75793 - 2003-07-10 09:32 AM Re: UDF calls
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes.
but, you only need to call them if they are in separate files.
if you have them in your script-file, you don't need to call them.
if you have them in separate file (all in single "library") you only need to call that file once and all the UDFs are included as kixtart function-procedures.
_________________________
!

download KiXnet

Top
#75794 - 2003-07-10 09:33 AM Re: UDF calls
didlyjack Offline
Fresh Scripter

Registered: 2003-07-09
Posts: 8
Thanks guys, that totally clears it up. Is that why I always see a 'break on' at the begining of the scripts that don't 'call' the .udf file?
Top
#75795 - 2003-07-10 09:40 AM Re: UDF calls
didlyjack Offline
Fresh Scripter

Registered: 2003-07-09
Posts: 8
Lonkero,
You said "you only need to call that file(library.udf) once and all the UDFs are included as kixtart function-procedures." Does that include any UDF's in scripts that are called from the first script?

[ 10. July 2003, 09:41: Message edited by: didlyjack ]

Top
#75796 - 2003-07-10 09:45 AM Re: UDF calls
didlyjack Offline
Fresh Scripter

Registered: 2003-07-09
Posts: 8
HAH, I answered my own question simply by reading what was right in front of me(fancy that). Theanswer to last question is YES!

Thanks a billion boys I totally understand now.
(But have no fear I'll be back.)

-J

[ 10. July 2003, 09:48: Message edited by: didlyjack ]

Top
#75797 - 2003-07-10 09:46 AM Re: UDF calls
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the CALL calls script-file.
it calls a single file.
whatever is included in that file is included in the calling script's "namespace" as part of the script.
let you figure out the rest [Wink]
ask again if still fussy.

then, "break on" has nothing to do with this.
break on is used in situations where user wants to be able to KILL the script execution... force it to shutdown during execution.
this is handy if your script is only a testversion and you are uncertain does it go to infinite loop or not.
although, for WKIX32.exe you don't need to specify that as forced shutdown is already enabled.
it seems to come most as a habit.
they put it in every script just to be sure.
others (like me) never use.
firstly, I use wkix32.exe so it's not needed and secondly I don't have need to kill my scripts so often [Wink]
_________________________
!

download KiXnet

Top
#75798 - 2003-07-10 09:48 AM Re: UDF calls
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you were quick.
NTDOC, these types of questions could fit in asked&answered section, no?
_________________________
!

download KiXnet

Top
#75799 - 2003-07-10 10:01 AM Re: UDF calls
didlyjack Offline
Fresh Scripter

Registered: 2003-07-09
Posts: 8
Thanks Lonkero,

I truly appreciate the word "quick" from you about me and my KixTart thinking. Just in case here's my untested script:
code:
 Call library.udf

; define task
$name='demo.job'
$name1='demo2.job'
$user='administrator'
$pw='adminpassword'


; enumerate all computers
$domaincomps=comnetview()
; schedule task for each computer
For Each $comp In $domaincomps
? 'Scheduling task on '+$comp
$rc=scheduletask2($name,$name1,$comp,$user,$pw,)
Next
; exit with success code
Exit 0


with this as the fnSchedultask2() ( modified from Jens' UDF "Scheduletask()" )
code:
 Function scheduletask2($name, name1, $comp, $user, $pw,)
Dim $jtexe, $shellcmd, $retcode

If $name='' OR $name1='' OR $comp='' ;date='' OR $time='' OR $type=''
Exit 87
EndIf
If $user='' OR $pw=''; OR $comment=''OR $command=''
Exit 87
EndIf
If NOT VarType($parameters)
Dim $parameters
$parameters=''
EndIf

; this should point to your copy of jt.exe
$jtexe='jt.exe'
If NOT Exist($jtexe)
Exit 2
EndIf

; delete a potentially existing task
$shellcmd = $jtexe
$shellcmd = $shellcmd+ ' /SC '+$user+' "'+$pw+'"'
$shellcmd = $shellcmd+ ' /SM \\'+$comp
$shellcmd = $shellcmd+ ' /SD "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd

$shellcmd = $jtexe

$shellcmd = $shellcmd+ ' /SVJ '+$name

$shellcmd = $shellcmd+ ' /lJ '+$name1

$shellcmd = $shellcmd+ ' /SC '+$user+' "'+$pw+'"'

$shellcmd = $shellcmd+ ' /SM \\'+$comp

Shell '%COMSPEC% /e:1024 /c '+$shellcmd
$scheduletask=@ERROR
Exit @ERROR
EndFunction



[ 10. July 2003, 10:06: Message edited by: didlyjack ]

Top
#75800 - 2003-07-10 01:34 PM Re: UDF calls
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
First off, it's KiXtart, not KixTart!
Second, there is a FAQ that explains it.
Topic: How to use UDFs
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#75801 - 2003-07-10 01:51 PM Re: UDF calls
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
didly,

I'm really glad you asked about Break On ...

To my mind, Break On is a "courtesy statement" that all people should include in their posted scripts. Its a courtesy because even though folks test their scripts in their environments, and they work ... thats not to say that they will work (or maybe hang or loop) in someone else's environment. There is nothing more aggravating then being logged-off one's workstation after running a bad script ... so most regular members always include it.

-Shawn

[ 10. July 2003, 13:53: Message edited by: Shawn ]

Top
Page 1 of 1 1


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

Who's Online
0 registered and 765 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.111 seconds in which 0.073 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