two dimensional arrays

Results 1 to 2 of 2

Thread: two dimensional arrays

  1. #1
    Join Date
    Dec 1969

    Default two dimensional arrays

    Here is some code I have inherited from a shopping cart application that has many order lines for each order. <BR> Function initOrderLineArray()<BR> if not isarray(arrOrderLines) then<BR> initOrderLineArray = False<BR> exit function<BR> else<BR> redim arrOrderLines(2,1)<BR> arrOrderLines(0,0) = "Product ID"<BR> arrOrderLines(1,0) = "Quantity Ordered"<BR> initOrderLineArray = True<BR> end if<BR> end function<BR> <BR> sub saveOrderLineArray()<BR> Session("OrderLineArray") = arrOrderLines<BR> Redim arrOrderLines(2,1)<BR> end sub<BR> <BR> function restoreOrderLineArray()<BR> if not isArray(arrOrderLines) then<BR> arrOrderLines = Session("OrderLineArray")<BR> end if<BR> if isArray(arrOrderLines) then<BR> for lngCount = 1 to ubound(arrOrderLines,2)<BR> if arrOrderLines(1,lngCount) &#062; 0 then<BR> Session("lngNumberofItems") = 1<BR> end if<BR> next<BR> restoreOrderLineArray = True<BR> <BR> else<BR> restoreOrderLineArray = False<BR> end if<BR> end function<BR> <BR> sub deleteOrderLineArray()<BR> Session("OrderLineArray") = ""<BR> Session("lngNumberOfItems") = 0<BR> redim arrOrderLines(2,1)<BR> end sub<BR><BR>As far as I can see, option base remains as default.<BR><BR>Here is what I don&#039t understand :<BR><BR>Does redim arrOrderLines(2,1) mean it is creating a two dimensional array with 3 &#039rows&#039 (first dimension) and 2 &#039columns&#039 (second dimension) ?<BR><BR>Is arrOrderLines(1,0) referring to the second element of the first dimension and the first element of the second dimension ?<BR><BR>if so, I don&#039t understand this bit<BR><BR>arrOrderLines(0,0) = "Product ID"<BR>arrOrderLines(1,0) = "Quantity Ordered"<BR><BR>Does<BR><BR>ubound(arrOrderLines,2 )<BR><BR>mean the upper limit of the second dimension for the array arrOrderLines ?<BR><BR>Lastly, don&#039t understand what this is saying :<BR><BR>if arrOrderLines(1,lngCount) &#062; 0 then<BR> Session("lngNumberofItems") = 1<BR> end if<BR><BR>Any help gratefully received, or links to useful vbscript tutorial/array sites. <BR><BR>Thanks.<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: two dimensional arrays

    &#062;mean the upper limit of the second dimension for the array<BR>&#062;arrOrderLines ?<BR><BR>yes<BR><BR><BR>&#062;if arrOrderLines(1,lngCount) &#062; 0 then<BR>&#062;Session("lngNumberofItems") = 1<BR>&#062;end if<BR><BR><BR>not sure what this is used for because it&#039s not used in this piece of code, simply assigning this session variable Session("lngNumberofItems")

Posting Permissions

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