Results 1 to 7 of 7

Thread: Array, No-way!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Hi,
    I can't seem to find a way to make an array of "num" things that;is created dynamically,limmited to "num",when "num" is reached drop the first thing and add another thing to the last position so a loop can scroll through the collection each time a thing is entered into the array "num" times.
    Any help on this?
    Thanks in advance,
    JoeyO

  2. #2
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550
    WHAT??????? Please clarify or I'll send you a picture of Kenny G...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Oh No!OK I'll try to clarify!

    'Suedo code

    Private Sub That_I_will_Call_Again_and_Again

    MyArray(begginNum to endNum)

    MyArray.addItem newThing

    For num = begginNum to endNum
    'Do things to MyArray
    'Find endNum to know how big
    If endNum > Limit_That_I_input then
    get rid of array member living in the (0) index spot
    subtract 1 from all the array members indexs
    end if
    Next
    'when I leave loop I'll probably add a new newThing

  4. #4
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    an array would work this but why use an array, I would use a queue.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    I'm not familiar with queue. Any Info? While I'm here though, I'd still like to know how to do this with an array and now; with a queue too.
    thanks

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Command1_Click()
    
    'added a listbox for display purpose only
    Dim MyArray()
    Dim num As Integer
    
    'fill the array with 4 items (1,2,3,4)
    For num = 1 To 4
    ReDim Preserve MyArray(num)
    MyArray(num) = num
    Next num
    
    'we now have an array with four items
    
    'MyArray.addItem newThing (this is garbage..you can't add ot
    'an array with additem)
    
    
    'We now have an array with 4 items (1,2,3,my new string)
     
    'Do things to MyArray
    'Find endNum to know how big
    
    'your array is limited to UBound (Upper Limit) so
    'UBound is the length you can specify
     
    For num = LBound(MyArray) To UBound(MyArray)
       If num = UBound(MyArray) Then
          MyArray(num) = "my new string"
       End If
    Next
    'you have already added it
    
    'display the finished product
    
    For num = 1 To UBound(MyArray)
      List1.AddItem MyArray(num)
    Next
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Ok thanks for trying but I need to release whatever value is held in array index #0(1st position) and replace it with the value of #1(in the 2nd position). Therefor index#3(currently in the 4th position) should become index#2(in the third position)and read "my new string" on the second pass through.
    Sorry for the crappy suedocode - I hurried.

    Please change this for a better visual so the 4th pass through makes the list read my new string 0,my new string 1,my new string 2,my ... ;

    'from this;
    For num = LBound(MyArray) To UBound(MyArray)
    If num = UBound(MyArray) Then
    MyArray(num) = "my new string"
    End If
    Next


    'To;
    For num = LBound(MyArray) To UBound(MyArray)
    If num = UBound(MyArray) Then
    Static i As Integer
    MyArray(num) = "my new string " & i
    i = i + 1
    End If
    Next

    Thanks for helping out. It's dropping the firstmember of the collection thats really bothering me. I used code to do this without dropping the used up parts of the array on a graphics program that held x,y positions and crapped out around 700,000 entries by filling up the virtual memory

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width