Can anybody suggest anyway to speed this code up. It works okay, but
its rather slow.
deflng a-z
DIM Arg$(2) 'Array to hold the arguments
MaxArg% = 2 'Maximum number of arguments
'
' To demonstrate CLINE, simply compile this program inside Quick Basic
' or from the command line.
'
'defsng a-z
CLS
CALL ParCline(Arg$(), MaxArg%, Res%)
if arg$(1) = "" then
cls
Print "command Usage: pnccass <Input file> <output file>"
end 10
end if
test$ = dir$(arg$(1),16) 'test for exist of file shown on command line
if test$ = "" then
cls
print "input file on command line doesn't exist try again"
print "check directory for exist of the file"
end 10
end if
if arg$(2) = "" then
cls
print "output file on command line is missing try again"
'print "check directory for exist of the file"
end 10
end if
testx$ = dir$(arg$(2),16) 'test for exist of file shown on command line
if testx$ <> "" then
kill arg$(2)
end if
open arg$(1) for binary lock read write as #1 len = 8192
open arg$(2) for binary as #2
do
finalline$ = "" 'reset variables between each block
start = 1
get$ #1,8000,datablock$
y = tally(datablock$,chr$(13)) 'count the occurances of 0D in the data block
for x = 1 to y 'use this number in the for loop to process entire block
position = instr(start,datablock$,chr$(13))
size = position - start
getline$ = mid$(datablock$,start,size)
start = start+size+2
if x = 1 then
ibm1$ = chr$(0)+chr$(sizeremain+size+4)+chr$(0)+chr$(0)
totalline$ = ibm1$+remainder$+getline$ 'add remainder line from last block to first line of next block
else
ibm$ = chr$(0)+chr$(size+4)+chr$(0)+chr$(0)
totalline$ = ibm$+getline$
end if
finalline$ = finalline$+totalline$ 'accummulate the block until then place put it to a file
next x
'block size in ibmvb must be in ascii characters therefore get length integer
'divide by 256 (position 2) and get remainder of integer division (position 1) ex. ÍÍ
finalsize = len(finalline$)
block1 = (finalsize mod 256):block2 = (finalsize \ 256)
blocksize$ = chr$(block1,block2,205,205)
put$ #2,blocksize$
put$ #2,finalline$
remainder$ = mid$(datablock$,start) 'the data breaks at 8000 bytes the last character is probably not
sizeremain = len(remainder$) 'a 0D0A there the for loop won't pick up so include it and add to begin of first line of next processed block
loop until eof(1)
close
end
$include "clinesub.bas"
------------------
its rather slow.
deflng a-z
DIM Arg$(2) 'Array to hold the arguments
MaxArg% = 2 'Maximum number of arguments
'
' To demonstrate CLINE, simply compile this program inside Quick Basic
' or from the command line.
'
'defsng a-z
CLS
CALL ParCline(Arg$(), MaxArg%, Res%)
if arg$(1) = "" then
cls
Print "command Usage: pnccass <Input file> <output file>"
end 10
end if
test$ = dir$(arg$(1),16) 'test for exist of file shown on command line
if test$ = "" then
cls
print "input file on command line doesn't exist try again"
print "check directory for exist of the file"
end 10
end if
if arg$(2) = "" then
cls
print "output file on command line is missing try again"
'print "check directory for exist of the file"
end 10
end if
testx$ = dir$(arg$(2),16) 'test for exist of file shown on command line
if testx$ <> "" then
kill arg$(2)
end if
open arg$(1) for binary lock read write as #1 len = 8192
open arg$(2) for binary as #2
do
finalline$ = "" 'reset variables between each block
start = 1
get$ #1,8000,datablock$
y = tally(datablock$,chr$(13)) 'count the occurances of 0D in the data block
for x = 1 to y 'use this number in the for loop to process entire block
position = instr(start,datablock$,chr$(13))
size = position - start
getline$ = mid$(datablock$,start,size)
start = start+size+2
if x = 1 then
ibm1$ = chr$(0)+chr$(sizeremain+size+4)+chr$(0)+chr$(0)
totalline$ = ibm1$+remainder$+getline$ 'add remainder line from last block to first line of next block
else
ibm$ = chr$(0)+chr$(size+4)+chr$(0)+chr$(0)
totalline$ = ibm$+getline$
end if
finalline$ = finalline$+totalline$ 'accummulate the block until then place put it to a file
next x
'block size in ibmvb must be in ascii characters therefore get length integer
'divide by 256 (position 2) and get remainder of integer division (position 1) ex. ÍÍ
finalsize = len(finalline$)
block1 = (finalsize mod 256):block2 = (finalsize \ 256)
blocksize$ = chr$(block1,block2,205,205)
put$ #2,blocksize$
put$ #2,finalline$
remainder$ = mid$(datablock$,start) 'the data breaks at 8000 bytes the last character is probably not
sizeremain = len(remainder$) 'a 0D0A there the for loop won't pick up so include it and add to begin of first line of next processed block
loop until eof(1)
close
end
$include "clinesub.bas"
------------------
Comment