[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Loading and writing arrays to a file



Phil,

move 0 to #i
while #i < #bookings_array_count
   get $product $bookings_class from bookings_array(#i)
      product bookings_class
   let $line = '"' || $product || '","' || $bookings_class || '"'
   move 0 to #j
   while #j < 156
      add 1 to #j
      get #quantity from bookings_array(#i) quantity(#j)
      move #quantity to $quantity edit 88888888
      let $line = $line || ',' || $quantity
   end-while
   write {OUT_FILE} from $line
   add 1 to #i
end-while

If we had used a break, it would have caused us to exit the loop
as soon as the BREAK is encountered.  For example:

move 0 to #i
while #i < 2
   show 'howdy'
   break
   show 'podner'
   add 1 to #i
end-while

only causes "howdy" to be displayed.  While:

move 0 to #i
while #i < 2
   show 'howdy'
   if #i > 0
      break
   end-if
   show 'podner'
   add 1 to #i
end-while

causes "howdy", "podner" , "howdy" to be displayed.

HTH.

Ray
> I am new to SQR and am having difficulty loading an array and then writing it to a
> delimited file.
>
> First Question:
>
> When executing a while loop, what lines get executed once the condition has been set
> to false.  I understand that if the while contains a BREAK that the commands
> immediately following the end-while are executed.  However, if the while does not
> contain a BREAK but the condition becomes false and the loop terminates do the
> commands immediately following the end-while get executed before the next record is
> selected from the database?
>
> Second Question:
>
> Following is the code I used to create the array:
>
> create-array name=bookings_array size =500
>      field=product:char
>      field=bookings_class:char
>      field=quantity:number:156=0
>
> Becasue of the occurs 156 times on the quantity field what do I need to do to get the
> entire record to a delimited file that can be opened in excel.
>
> Any help would be appreciated.
>
> Phil Roell
>

----------------------------------------------------------------------
Ray Ontko       |  Ray Ontko & Co  |  "Time for a new signature line."
rayo@ontko.com  |  Richmond, In    |  See us at http://www.ontko.com/