Dave using your format:

' Inside your script declaration section, (above all procedures and 
functions makes it more readable.)
Dim ArrayOfSets(), Set1, Set2, Set3

'Immediately following the declaration above or before any data storage 
calls make an estimated size to your sets and quantity of sets.

Redim arrayOfSets(10), Set1(50), Set2(50), Set3(50)
' Above you set a max of 51 numbers for each set and only 11 sets; noting 
that 0 is the starting point and VB does not allow a starting point of 1.

arrayOfSets(0) = Set1: arrayOfSets(1) = Set2: arrayOfSets(2) = Set3

'Now as I stated below, you can add numbers to each array by only using the 
first array and the value of it's row to indicate which set you want to 
store a number to; using a second set of parens.

arrayOfSets(0)(4) = 1024
'This assigns the value 1024 to the first set at position 5 but it is row 4 
of the first set because it is a 0 based system.

    So this should answer your question about sets and assigning numbers to 
multiple sets inside one array.

You can also label each row of the first array, or a name to each set by 
setting up a dictionary that uses integer numbers as the data for each 
element. Then use that dictionary name with a label name for the set to have 
that dictionary name call that specific set by name. The below program uses 
2 methods to assign a value to a dictionary, the add or ().
Example for making set arrays:

Dim ArrayOfSets(), Set0, Set1, Set2
Redim arrayOfSets(10), Set0(50), Set1(50), Set2(50)

arrayOfSets(0) = Set0: arrayOfSets(1) = Set1: arrayOfSets(2) = Set2

arrayOfSets(0)(4) = 1024

Dim SetName
Set SetName = CreateObject("Scripting.Dictionary")
SetName.Add "Set0", 0
SetName.Add "Set1", 1

arrayOfSets( SetName( "Set1"))(4) = 2048

SetName( "Set2") = 2
arrayOfSets( SetName( "Set2"))(4) = 4096

msgBox " Set 0 element 5 is: " & arrayOfSets( SetName( "Set0"))(4)
msgBox " Set 1 element 5 is: " & arrayOfSets( SetName( "Set1"))(4)
msgBox " Set 2 element 5 is: " & arrayOfSets( SetName( "Set2"))(4)

Sent: Wednesday, February 29, 2012 5:34 PM
Subject: Re: Very Large Array Storage





Hi Again Dave,

    I clarified it better and the second set of examples are what you are
looking for. How to first initialize the arrays. Really only needing 2 to
get started, one to say it is an array, then the second array to assign to
the first dimension element of the first one to indicate the array of
arrays.
    Then I set initial dimensions of the array which can be changed at any
time larger or smaller; but smaller you will loose data after that ReDim has
been used if data already existed inside. Remember to use the "ReDim
Preserve" format to keep all stored data in the arrays being resized.

    This is more of the example I stated before.
    Note that you assign each array there dimensions. Then place your values
in within the limits you made. Now, if you want to expand the list, as you
call it, the procedure add, then just use the ReDim Preserve statement to
the array you wish
to enlarge as the substitute for add.
    Also, if you want to add more arrays, then just declare that array or
expand the original array of arrays and you have another list of numbers
referenced by the row number of the array of arrays you first established.


' Making an array of arrays:
ar = Array( Array(10, 11, 12, 13, 14, 15), _
Array(100, 102, 104, 106, 108, 110))

Dim result: result = ar(1)
msgBox result(1)
Your display is: 102
msgBox ar(1)(2)
Your Display Is: 104
msgBox ar(0)(5)
Your Display Is: 15

'Making an array of arrays using the dynamic format:
Dim ar1(), ar2(), ar3()

'Anywhere in your program you set a size for those arrays:
Redim ar1(10), ar2(20), ar3(30)

'Now immediately after but not necessary, make assignments which will force
a type for the variant as it initially exists:
' The first array is being used as an array of arrays:
ar1(0) = ar2
ar1(1) = ar3

'Now inside any procedure or function call inside your script make your
assignments or integer values or numbers to that array of arrays depending
on where you want them stored by element or row number:
ar1(0)(5) = 5
ar1(1)(15) = 15

'Now test your stored numbers based on row of array of the array row you
placed the numbers above:
msgBox ar1(0)(5)
msgBox ar1(1)(15)

    Above I made 3 arrays and the second and third ones were placed inside
the first one, thus making an array of arrays.

    Then under the format of several parens you assign a number to the
element of the array that is inside the other array.

    You can keep on doing this for as long as you want, but remember that
only 60 dimensions in an array.
Meaning 60 numbers inside the outer parens separated by commas.
Example using numbers to only indicate the dimension number:
ar(1, 2, 3, 4,...60)
        Sincerely
        Bruce

Sent: Wednesday, February 29, 2012 4:19 PM
Subject: RE: Very Large Array Storage


Hi, Jeff,
Here are some specifics although I'm really interested in the
approach to solving this sort of problem, not just this specific one.

Imagine 8,500 integers organized into 50 different sized sets labeled
Set0, Set1, ... Set49.
Since the various sets have a different number of integers in each
one, I think of that as consistant with the definition of a dynamic
array. That's how I get the 50 dynamic arrays. Specifically,
Set0 = (12, 32012, 430, ... [to-some-last-value] 519) ' N0 number of
integers and now they are countible, but not before the set is populated!
Set1 = (some-number-of-integers) ' Now I know there are N1 number of
integers not known ahead of time.
...
Set49 = (Yet-Another-Group-of-Integers) ' There are now known to be
N49 number of integers after the fact.

If I knew how to capture these 50 lines of text output from my
script, with each establishing the sets 0..49, I could simply write
the results of the algorithm into a text file, cut and paste the data
into my script and be done with it. However, some of the sets
(arrays, lines, or however you think of them) have very long text
lines which make it too difficult to edit cleanly and without errors.
This is not an attractive option when writing a script. I am assuming
I must complete the population of each setN within the bounds of one
line of text for the interpreter. Is that even true?

Alternatively, I could use the algorithmto perform an Add function on
a dynamic array using the DynArray object and its methods. That
ultimately means 8,500 lines like:
Set0(0) = DynArray.Add([output-from-algorithm and location identifiers])
Set0(1) = DynArray.Add(...)
Set0(2) = DynArray.Add(...)
..
Set49(last) = DynArray.Add(...)
with the output from the algorithm being added to the specific array.
This is also very unattractive for the same reasons.

So, how to capture the dataset; and, how to write (define) the
dataset? Specifically, how do I capture the output from my algorithm
into a text file for later reference/addition into the script? As an
alternate, how do I declare and define the DataSet within the
confines of a .vbs file?

You can see there is but one static array, the one like: dim
DataSet(50). Their definition might be:
dim Set0 : HOW to write out the full set of its integers??

DataSet(0) = Set0
and so on until:
DataSet(49) = Set49

Finally, can I define all this data just once, at global script
initializations when WE starts? I do not want to generate all that
data each time the user activates the app with a hotkey. Once the
algorithm computes each integer and it is saved in its proper
location, that integer never changes in value; never changes in
location; and is never written into the dataset again. With compiled
languages, this is almost trivial. But, with an interpreted language,
things are different. I do not know how WE loads, initializes, and
then executes scripts once the user presses the activating hotkey. I
hope knowing such implementation details is not needed. A general
overview might be helpful though.

For example, is it possible to put the DataSet into that part of the
script outside of any function or sub? I thought I would have to
include the DataSet definitions within the scope of the routines
called when the app executes. Maybe that is a false assumption.

I hope this is clear. I do not know how to make it clearer. I
certainly do appreciate your taking the time to help me with this. We
may need to talk offline. If you'd like, call me at 858: 565-4327
from 9am to 9pm PST.

Dave


At 05:53 AM 2/29/2012, you wrote:
>VBScript arrays are variants and can store anything you need to, inluding
>other arrays, dictionary objects, etc. In addition, Dictionary objects can
>do the same thing.
>
>With more information on what you are doing may help in solving the puzzles
>you are attempting to accomplish.
>
>
>-----Original Message-----
>From: David Helkenn [mailto:[email protected]]
>Sent: Tuesday, February 28, 2012 10:10 PM
>To: [email protected]
>Subject: Re: Very Large Array Storage
>
>Thank you, Bruce. I thought I would use the DynArray facility from the
>toolkit since I know I have the 50 static entries in the first dimension.
>If
>I were doing this in C, I would actually have the elements of this
>dimension
>50 array consist of pointers to integer arrays, one at each index. I would
>build this array by locating the index into the 50 static array and then
>append another integer onto the end of the integer array pointed to by that
>entry. I thought I could use the DynArray method 'add' to accomplish this.
>
>The trouble is, I'm not doing pointers. I see no way of declaring the first
>and static array which has a known size after all, of being an array of
>dynamic array elements. I know the integers in each dynamic array are
>sorted
>as I build the thing. I plan to use other variables to track locations
>within the dynamic array of integers etc.
>
>So, that is one problem, how to tell VBScript that the staticArray(5) has a
>DynamicArray() which may have indexes from 0 to the method 'total' or
>'count' (I forget what it is called exactly. In programming languages, one
>usually has to specify the elements the array contains. int *StaticArray[]
>comes to mind. The compiler understands that the array StaticArray is of
>unknown length and points to int; that is StaticArray is an array of
>pointers to int.
>How does VBScript come to "understand" that in my case, StaticArray is an
>array of known length, but that the elements of that array are themselves,
>arrays of integers?
>
>The second problem is how to store about 8500 integers? Again, I want this
>to be a global script. Usually there is some sort of initialization doen on
>an instance of an object. I can't remember the term for it, but when the
>object is instantiated, there is an implied initialization of that object
>before its properties and methods are available. Even when the object is
>done with and destroyed, there is some 'finalization" or clean up to take
>care of resource reclaimation etc.
>
>So, if I could do the initialzation when this global script starts, the
>integers would be there and the routines invoked at script activation time
>would find the arrays ready for reading. By the way, the integers are all
>read only. The user may not fiddle with the data set in any way, except to
>read them. No writing allowed. If the script is unloaded, the memory and
>any
>other overhead resources could be reclaimed. I don't know how to do this
>sort of stuff.
>
>Thanks for the help. This is certainly an interesting challenge for me!
>
>Dave
>
>
>
>At 01:17 PM 2/28/2012, you wrote:
>
> >Hi Dave,
> >
> >     You first dim your array with just () or parens.
> >     At any time you can add to or delete from the array using the
> >redim statement.
> >Now, to preserve existing data you use the word preserve. without that
> >word all data in your array is lost.
> >
> >     Now the next thing is you can increase size or dimensions but can
> >not do the reverse. ReDim takes the last dimension and increases it, or
> >adds another dimension on to it.
> >     So you can erase the entire array by just given it a dim or redim
> >command.
> >Format:
> >'In the app body or init section
> >Dim YourArray()
> >' Make an initial size of 40 with no data inside.
> >ReDim YourArray(40)
> >' When Inside sub or functions increase the size:
> >ReDim Preserve YourArray(6000)
> >' To Increase dimensions:
> >ReDim Preserve YourArray(6000, 4)
> >'Note:
> >'    Remember you can not go backward or any data in those dimensionns or
> >locations will be lost.
> >'Such as
> >ReDim Preserve YourArray( 6000, 2)
> >'You have lost all data in the 3'rd and 4'th dimensions.
> >ReDim Preserve YourArray(6000)
> >'You lost all data in the second dimension.
> >ReDim Preserve YourArray(40)
> >'You are now down your original size and all data above that is lost.
> >
> >     I hope this helps. Any saving of data for future useage either put
> >them in an iniFile or external file as mentioned by others.
> >         Bruce
> >
> >Sent: Tuesday, February 28, 2012 12:22 PM
> >Subject: RE: Very Large Array Storage
> >
> >
> >Hello,
> >Thanks for your reply. I'm not actually polling anything. I refered to
> >the collection (not a technical term, just a set) of arrays to hold
> >integers in an organized manner. They are more like mapping arrays and
> >ordered integers. An anology would be an static array of of dynamic
> >arrays like a list of variable length strings.
> >
> >Thanks...
> >
> >Dave
> >
> >
> >At 07:56 AM 2/28/2012, you wrote:
> > >What kind of database are you pulling from? Will you be using SQL to
> > >perform the retrieval?
> > >
> > >-----Original Message-----
> > >From: David Helkenn [mailto:[email protected]]
> > >Sent: Tuesday, February 28, 2012 8:55 AM
> > >To: [email protected]
> > >Cc: [email protected]
> > >Subject: Very Large Array Storage
> > >
> > >Hello,
> > >I want to write an app that will require a fairly large database
> > >organized in arrays. There are around 8500 integer elements to be
> > >stored in some 35 arrays. I thought I could have a static array of
> > >the 35 dynamic arrays containing the integers. However, I do not know
> > >how to get all that data initialized prior to the invokation of the
> > >rest of the app. How do I get that data known to the app?
> > >
> > >The behavior from a very high view, is the user presses the
> > >activation hotkey, the controls are displayed in the dialog and the
> > >database is available for use. I do not know how long it will take to
> > >create the database, but it is subject to an easily implemented
>algorithm.
> > >
> > >I am hoping to have this app as global. Will I need to use a file? If
> > >so, where is the documentation related to the file system? I find
> > >only a file/dir related document but there is no FSO in the GW
> > >toolkit. Help please.
> > >
> > >Using Windows7pro64 and WE 7.5.3.
> > >
> > >Thanks...
> > >
> > >Dave

Reply via email to