Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Multi dim arrays in multi dim arrays... is it safe?

    I have good reason to do this... I figure it might b quite unconventional but it is safe?

    Code:
    folders(0,0) = folderId
    folders(1,0) = typeData
    
    typeData(0,0) = typeId
    typeData(1,0) = typeName
    typeData(2,0) = articleData
    
    articleData(0,0) = aId
    articleData(1,0) = aTitle
    .
    .
    .
    .
    .
    You get the idea... is it safe? Nested arrays? Is that even wot its called?
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, this is what is called nested arrays. An array within an array. I started my career as an xbase programmer (dbase and clipper, you may or may not have heard of them) but anyway, nested arrays were very common. Plus the arrays were always dynamic. I do not really understand your question about whether it is safe or not. Could you amplify.

    BaldEagle

  • #3
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by BaldEagle
    Yes, this is what is called nested arrays. An array within an array. I started my career as an xbase programmer (dbase and clipper, you may or may not have heard of them) but anyway, nested arrays were very common. Plus the arrays were always dynamic. I do not really understand your question about whether it is safe or not. Could you amplify.

    BaldEagle
    I infer from ur response that since they are common there's nothing unconventional or unsafe (programming wise) with them
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #4
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, that was my implication, but I was thinking that you may have some knowledge pertaining to their use in the environments that we discuss here that may make them less than desirable. If that is not the case then I would say they are certainly safe to use, however, they can be a little tricky if the programmer is not used to using them. What I mean is if everyone working on an application can easily manipulate them then they are certainly powerful indeed. For an inexperienced programmer they can be hell to figure out.

    BaldEagle

  • #5
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by BaldEagle
    Yes, that was my implication, but I was thinking that you may have some knowledge pertaining to their use in the environments that we discuss here that may make them less than desirable. If that is not the case then I would say they are certainly safe to use, however, they can be a little tricky if the programmer is not used to using them. What I mean is if everyone working on an application can easily manipulate them then they are certainly powerful indeed. For an inexperienced programmer they can be hell to figure out.

    BaldEagle
    I'm not an experienced coder in asp... i hav but little experience.. but the concept of multidimensional arrays is not new me..
    thanks
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #6
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I apologize if you thought I was referring to your level of knowledge. I was only speaking in general terms. I work in shops with many people assigned to a particular application and all are not at the same level of expertise. Subsequently we have to eliminate some of the trickier aspects of the coding language to allow the less experienced to still function within the group. This is done only when other alternatives exist, otherwise the particular project is handled by only experienced people that can implement this code and the newbies are pressed to learn as quickly as possible.

    Again, I was in no way referring to your particular situation or knowledge. If my words offended you I am very sorry. That was not my intent.

    BaldEagle

  • #7
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You mean multi-dimensional arrays? Yeah there isn't anything wrong with using them. However if you ever use more than 3 dimensions then you are probably doing something pretty funky.
    OracleGuy

  • #8
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    whats the proper way to declare a multidimensional array? And then whats the proper way to obtain the number of rows and cols in the array... I've been getting alot of subscript out of range errors
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #9
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <%
    Dim aryData(cols, rows)
    Dim iRow, iCol
    Response.Write "<table>" & vbcrlf
    For iRow = 0 To Ubound(aryData, 2)
    	Response.Write "<tr>" & vbcrlf
    	For iCol = 0 To Ubound(aryData, 1)
    		Response.Write "<td>" & aryData(iCol, iRow) & "</td>" & vbcrlf
    	Next
    	Response.Write "</tr>" & vbcrlf
    Next
    Response.Write "</table>" & vbcrlf
    %>

  • #10
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by BaldEagle
    I apologize if you thought I was referring to your level of knowledge. I was only speaking in general terms. I work in shops with many people assigned to a particular application and all are not at the same level of expertise. Subsequently we have to eliminate some of the trickier aspects of the coding language to allow the less experienced to still function within the group. This is done only when other alternatives exist, otherwise the particular project is handled by only experienced people that can implement this code and the newbies are pressed to learn as quickly as possible.

    Again, I was in no way referring to your particular situation or knowledge. If my words offended you I am very sorry. That was not my intent.

    BaldEagle
    No need for apologies man... no harm done thanks for ur help... I appreciate it
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #11
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Alright... here are my questions:
    How do I declare a multidimensional array without defining how many rows it will have? (I know the amount of columns it will have, thats fixed.)

    How do I check back the array to see if data has been added to it?

    How do I check the current index row of the array so i can know what index to place for "row" Redim Preserve myArray(cols,row+1)?
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #12
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jaywhy13
    Alright... here are my questions:
    How do I declare a multidimensional array without defining how many rows it will have? (I know the amount of columns it will have, thats fixed.)

    How do I check back the array to see if data has been added to it?

    How do I check the current index row of the array so i can know what index to place for "row" Redim Preserve myArray(cols,row+1)?

    1. Since you already know there will be at least one row you can just make the initial Dim contain one. Dim myArray(5,1) then ReDim Preserve from there.

    2. If you want to do this strictly for peace of mind then you could create a sub or function to dump the contents of the array to the screen so you could observe it. Otherwise assigning values to the array is no different than any other variable assignment. (see neocool00 post)

    3. You can use a variable to keep track or you can use the Ubound function.
    next_row = Ubound(myArray,2) +1 ' 2 is for the second dimension
    Redim Preserve myArray(cols,next_row)

    BaldEagle

  • #13
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Is there a limit to the amount you can do? Coz I'm getting a subscript error now that only comes about when I try to go beyond column 5. If I try to access column 6 it spits an error. And I already dimmed it properly
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #14
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There are limits but they are different for each machine because it is limited by memory. Certainly your first dimension being a 7 or greater should not be a problem unless your second dimension is very, very large. Post the code that is malfunctioning and we'll see how we can help.

    BaldEagle

    [edit] Also semantics are important when dealing with arrays. when you say column 6 do you mean the sixth column or the one numbered 6. The sixth column is actually numbered 5.
    Last edited by BaldEagle; 08-18-2005 at 02:57 AM.

  • #15
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by BaldEagle
    There are limits but they are different for each machine because it is limited by memory. Certainly your first dimension being a 7 or greater should not be a problem unless your second dimension is very, very large. Post the code that is malfunctioning and we'll see how we can help.

    BaldEagle

    [edit] Also semantics are important when dealing with arrays. when you say column 6 do you mean the sixth column or the one numbered 6. The sixth column is actually numbered 5.
    The limit is 60. Did some searching. I fixed the afore-mentioned problem. I made a silly mistake in my coding.. referred to the wrong multidimensional array. I also learned that you there are no inbuilt functions to measure dimensions in vbscript... but it can be done in JScript.
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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