Resize array

Just starting out? Need help? Post your questions and find answers here.
batcherx
New User
New User
Posts: 9
Joined: Mon May 24, 2004 5:34 am

Resize array

Post by batcherx »

In the following prog layout how can I resize arraysort.s in proc itemcollatesort?
Help file talks about resizing but gives no example/s.

THX

Dim arraysort.s(1) ; template array for itemcollatesort
; array can be between 1 and 10,000,000 elements
; arraysort.s(10000000) would take up 30M approx just for starters!
; resizing of arraysort.s done in itemcollatesort
Procedure.s Sortsomearray(x,y,z,a,b,c)
; routine to sort the array - easy
EndProcedure
Procedure.s itemcollatesort(filename$)
; work out # of lines in file - easy
; resize arraysort.s for # of element to match line # - BUT HOW???
; put lines into elements & sort via proc sortsomearray - easy
; return to Utilsort - easiest
EndProcedure
ProcedureDLL.s UtilSort(filename$)
; Do some initialisation - easy
; Determine sort required, go to proc itemcollatesort - easy
; put sorted elements of array into a temp file for caller - easy
EndProcedure
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

simple add a "dim arraysort.s(x)", but important: This will earse the array!

Maybe you should first copy the complete array in a helparray, redim, and then copy it back.
batcherx
New User
New User
Posts: 9
Joined: Mon May 24, 2004 5:34 am

Post by batcherx »

Great! thanks.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

You might find the discussion here interesting:

viewtopic.php?t=6160
Post Reply