#119436 - 2004-05-12 08:30 PM
using a central udf file
|
tr6boy
Starting to like KiXtart
Registered: 2001-10-24
Posts: 131
|
I think I've read here that it makes sense to bundle the various UDFs that you use into a single file, and then call it from your script. But is there a practical limit as to how large I should let it become?
It's probably unrelated, but running IsInSubnet with the function code in the same script is working fine, but calling it from another script is causing an error. It's not just that it can't find the file, it's saying "expected expression" in a line that is part of the function code.
I can't find anything wrong with it.
Exact Error is:
expected expression: $h=''+$h+iif($/8,'255',$f[$ mod 8])+iif($g<4,'.',''
which appears in this part of the UDF: Code:
;Begin build mask array (Howard Bullock) $f=0,128,192,224,240,248,252,254,255 for $e=0 to 32 Dim $h $=$e for $g=1 to 4 $h=''+$h+iif($/8,'255',$f[$ mod 8])+iif($g<4,'.','') $=iif($>8,$-8,0) next $m[$e]=$h next
|
|
Top
|
|
|
|
#119439 - 2004-05-13 04:35 PM
Re: using a central udf file
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
But is there a practical limit as to how large I should let it become?
Yup, when it becomes impractical to maintain, you've exceeded the practical limit.
There are a couple of consideration that would make you break down the file into smaller libraries.
The first is simply maintenance. It is unhandy having to edit a file with hundreds of functions in it, or to search through for a function who's name you've forgotten.
More important though, is that every file that you load is parsed. This happens when you "CALL" the file, and the entire file is parsed - not just the functions that you want to use.
Often the longest part of running a script is reading it from the network share and parsing it.
For this reason it makes sense to categorise you UDFs and store them in discrete libraries. You only need to call in the libraries that contain the functions you are going to use, saving memory and cpu.
For instance, I have seperate libraries for
- Logging UDFs
- Internationalisation UDFs
- String handling UDFs
- Email UDFs
- Network calculation UDFs
- Time and date UDFs
- Specific application UDFs
And so-on.
There are no more than 6 small functions in each of these, so they are quite quick to load and parse.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Henriques)
and 2516 anonymous users online.
|
|
|