Arrays.. are the possible??? 
Author Message
 Arrays.. are the possible???

Forgive my stupidity, but today i decided to sit down and try to write a vbs
file that would run as part of an NT logon script. It's purpose is to check if
the computer being logged into is one of a pre-selected list of computers, and
then carry out an action..

instead of having a lot of if then's i wanted to use an array and a for loop.
Are array's possible in VBS/WSH. or is there a more efficient way to check for a
value in a list of values??

any suggestions would be VERY much appreciated. reply to news or my email

thanks in advance,
Jethro Brewin.



Mon, 27 Jan 2003 03:00:00 GMT  
 Arrays.. are the possible???

Quote:

> Forgive my stupidity, but today i decided to sit down and try to write a vbs
> file that would run as part of an NT logon script. It's purpose is to check if
> the computer being logged into is one of a pre-selected list of computers, and
> then carry out an action..

> instead of having a lot of if then's i wanted to use an array and a for loop.
> Are array's possible in VBS/WSH. or is there a more efficient way to check for a
> value in a list of values??

> any suggestions would be VERY much appreciated. reply to news or my email

> thanks in advance,
> Jethro Brewin.

Arrays are possible, just Dim a variable with the appropriate bounds.  

  Dim MyArray(20)

Array lower bounds are always zero in VBScript.

Arrays can also be ReDim'ed, if they are loaded from a file of
indeterminate length.

  Dim MyArray
  Count = 0
  Do While not SomeStreamObj.AtEndOfStream
    ReDim MyArray(Count)
    MyArray(Count) = SomeStreamObj.ReadLine
    Count = Count + 1
  Loop

Or better yet ...

  MyArray = Split(SomeStreamObj.ReadAll, vbNewLine)
  For I = 0 to Ubound(MyArray)
    Wscript.Echo MyArray(I)
  Next

If you don't have proper documentation for VBScript, may I suggest a
trip to

  http://msdn.microsoft.com/scripting/default.htm

and more specifically:

  http://msdn.microsoft.com/scripting/vbscript/techinfo/vbsdocs.htm

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Mon, 27 Jan 2003 03:00:00 GMT  
 Arrays.. are the possible???
Tom,

many thanks for that... it's beginning to make sense now.. hankering back to the
days of university. :)

and the links were useful too as the next hurdle i had to tackle was file
manipulation...

again, thank you very much.

Jet'



Mon, 27 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. javascript array problem, or am I just stupid!!!

2. Possible bug with Array as prototype

3. Global JScript arrays - possible??

4. Array manipulation - is this possible?

5. Possible BUG with array and classes in VBS build 3715

6. Possible to Store Objects in Arrays?

7. Is it possible to return arrays from functions?

8. session array possible

9. Is it possible to inherit from Array?

10. wsh/ jscript : BUG : array of array, 2D array

11. Possible Possible ASP Scripting Enhancements: compilation, queuing, resident programs

12. Possible bug in WScript.Network **how do I check if I am logged i n to domain **

 

 
Powered by phpBB® Forum Software