Please note you wont be able to view/download the TEST.zip file if you have not registered on this forum . .
This is my simple code :-
'Size of each record is 3795
'Sort only column 31 (40 characters)
' CODE USING POWERBASIC
' OPEN THE RANDOM FILE
OPEN"test" FOR RANDOM ACCESS READ WRITE SHARED AS #1 LEN=3795
field#1,3795 as t$
NUM=LOF(1)/3795:' NUMBER OF RECORDS
dim huge t$(NUM)
for x=1 to NUM
get#1,x
t$(x)=mid$(t$,31,40)+"/"+str$(x): 'EXTRACT ONLY RECORDS THAT NEED TO BE SORTED
next x
PRINT"Busy sorting ..."
Flips = 1
WHILE Flips = 1
Flips = 0
FOR I = 1 TO Num - 1
IF T$(I) > T$(I + 1) THEN
SWAP T$(I), T$(I + 1)
Flips = 1
END IF
NEXT I
WEND
'WRITE THE RESULTS TO A FILE (SEQUENTIAL)
OPEN"O",#2,"TEST.SRT"
FOR I=1 TO NUM
PRINT#2,MID$(T$(I),42,10):'REM ONLY WRITE THE INDEX LOCATION
NEXT I
CLOSE#2
end
Test File
- basit
- Site Admin
- Posts: 200
- Joined: May 17th, 2005, 8:10 pm
- Location: Johannesburg South Africa
- Contact:
The Best Sorter will be made public with source code.
My solution using PowerBasic on the test file runs out of memory . . if the file size is reduced to less than 10000 records it sorts the file taking 6 minutes on a P4 3.GHZ with 2gig memory. The problem with power basic is that huge arrays has to fit within the 640 dos limits.
BASit
BASit
- basit
- Site Admin
- Posts: 200
- Joined: May 17th, 2005, 8:10 pm
- Location: Johannesburg South Africa
- Contact:
Starts at 1
In PowerBasic> if a string is like this t$="test1234567890" column 1 will have "t" in it and column five will have "1" , so for example you want to use four digits(7890) from the test string above you will use the mid$ command and start at column 11 an choose 4 digits >>> mid$(t$,11,4)
Hope this helps
BASit
In PowerBasic> if a string is like this t$="test1234567890" column 1 will have "t" in it and column five will have "1" , so for example you want to use four digits(7890) from the test string above you will use the mid$ command and start at column 11 an choose 4 digits >>> mid$(t$,11,4)
Hope this helps
BASit
-
Dejan Mitrovic
- Posts: 5
- Joined: July 11th, 2005, 12:42 pm