Page 1 of 1 1
Topic Options
#165039 - 2006-07-25 07:27 PM Simple question I hope
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Ok I have a function that I need to pass an entire array to.
Do I simply pass it like this
Code:

Function OfSomesort($array)


Or should I declare it as a global?
_________________________
Today is the tomorrow you worried about yesterday.

Top
#165040 - 2006-07-25 07:28 PM Re: Simple question I hope
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Pass it like that.
Top
#165041 - 2006-07-25 07:29 PM Re: Simple question I hope
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
At least you did not say
Quote:

pass it like gas




Top
#165042 - 2006-07-25 07:32 PM Re: Simple question I hope
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
rofl - tbh - much would depend on why your concerned about it ... is it a huge array or something ? because passing it like that is passing it by value - which implies a copy of the array will made.
Top
#165043 - 2006-07-25 07:34 PM Re: Simple question I hope
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Small array, just was unsure if you could pass the entire array or if it would just send the first element.
Top
#165044 - 2006-07-25 07:37 PM Re: Simple question I hope
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Here is what I am working on....
Code:
;*************************************************************************
; Script Name: NetDev_Config_Change
; Author: WAKimball
; Date: 7/25/2006
; Description: Use this script to apply changes to all network devices.
; This will apply the changes globally to ALL devices in the file
; DeviceList.txt. Input file should be located in the script dir, and
; named Input.txt
;
;************************************************************************* 

;Script Options
$SO=SETOPTION("Explicit", "ON")
$SO=SETOPTION("NoMacrosInStrings", "ON")
$SO=SETOPTION("NoVarsInStrings", "ON")
$SO=SETOPTION("WrapAtEOL", "ON")
BREAK ON
Dim $SO, $FH, $Device[], $Input[], $R, $$
   

$FH=FreeFileHandle()

If Open($FH, @ScriptDir+"\devicelist.txt",2)= 0
   
$R = Readline($fh)
   
$SO = 0
   
While @Error = 0
       
$Device[$SO] = $R
        $SO = $SO + 1
       
Redim Preserve $Device[$SO]
       
$R = Readline($fh)
   
Loop
    Close($FH)
Else ? "Error opening file"
EndIF

If Open($FH, @ScriptDir+"\input.txt,2)=0    
    $R = Readline($fh)
   
$SO = 0
   
While @Error = 0
       
$Input[$SO] = $R
        $SO = $SO + 1
       
Redim Preserve $Input[$SO]
       
$R = Readline($fh)
   
Loop
    Close($FH)
Else ? "Error opening file"
EndIF

For each $SO in $Device
    CLS
    ? "Please connect to: " + $SO
    ? "Press -C- once connected and in Exec mode"
    Press()
   
If Setfocus("Telnet "+$SO) = 0
        Send(
$Input)
   
Else
        If Setfocus("Putty "+$SO) = 0
            Send(
$Input)
       
Else
            ? "Unable to find Window"
        EndIf
    EndIf
Next


Function Press()
Dim $

While $ <> "C"
    Get $
Loop

EndFunction

Function Send($Input)
   
For each $$ in $Input
    CheckString($$)
   
SendKeys($checkstring)
   
Next
EndFunction


Function CheckString ($letters)
Dim $letters, $a, $i, $s
$a = ""
For $i= 1 to Len($letters)
$a = Substr($letters, $i, 1)
   
Select
        Case $a = "+"
        $a = "{+}"
        Case $a = "^"
        $a = "{^}"
        Case $a = "~"
        $a = "{~}"
        Case $a = "("
        $a = "{(}"
        Case $a = ")"
        $a = "{)}"
        Case $a = "{"
        $a = "{{}"
        Case $a = "}"
        $a = "{}}"
    EndSelect
$s = $s+$a
Next
$checkstring = $s
EndFunction



Top
#165045 - 2006-07-25 07:41 PM Re: Simple question I hope
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
cool, no - there are many UDFs (like the sorters) that take an array as a parameter - and sorts the array - then passes an array back.
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 293 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.053 seconds in which 0.023 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