Flex strings are still supported in the current version of PB/DOS.
FYI, UDT's are a *companion* feature, rather than a replacement for flex strings. The key differences between then is that flex strings can be dynamically created, resized and destroyed at runtime, whereas UDT's are have a fixed size that must be determined at compile time.
Therefore, if the data structures are "static" (that is, there size and format is not going to change at runtime), then UDT's can offer better runtime performance, because there is no runtime requirement to calculate data positions in memory, etc.
However, if the data format is changable, then flex strings provide an excellent and versatile way to manipulate data and sub-sets of data.
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Announcement
Collapse
No announcement yet.
This runs slowly
Collapse
X
-
Flex strings are fixed-length strings that you can sub-divide into several smaller strings. They've been superceded by more versatile user-defined types in later versions of PB.
Look up the MAP statement on your PB documentation - it gets almost 5 pages in the PB 2.00 Reference Guide, and flex strings have a whole 2 pages in the Users Manual.
------------------
--Dan
Leave a comment:
-
What are Flex Strings (the documentation I have only briefly
mentions them) and what are the advantages of using them??
------------------
Leave a comment:
-
Hi Martin,
Your code is very clear but...
1) use only Binary opened file -> speed
(may be You need some chr$(13,10) CR+LF after the text)
2) If You put$ or print #3 some text to the file put them
first together
yours:
print #3," B 0" '21 - 2nd of 2 pages
print #3," B *"
better:
crff$=chr$(13,10)
saven1$=" B 0"+crff$+" B *"
saven$ =" B 0"+crff$+" B *"+crff$
print #3,saven1$ --- in output modus
put$ #3,saven$ --- in binary modus
3) what is this ? ---- This needs lots of time
print #3," A ";left$(right$(ltrim$(str$(statements)),2),1)
amount1$ = ltrim$(rtrim$(mid$(idx$,4,14))) '6f
print #3," A ";right$(right$(rtrim$(str$(statements)),2),1) 'uses pages count in
---> right$(right$(...,2),1) is the same how right$(...,1)
there must be a simpler way to reach the same
is your data not formated ?
look for Flex Variables in Your PB-Book
You have a lot of work with Your "small" program.
Regards
Matthias Kuhn Germany
------------------
Leave a comment:
-
This runs slowly
I have a small program that runs rather slowly (a prexisting c/c++
program running the same data is roughly 10 times faster, although
this program is far simpler). Can anybody suggest ways to speed this
up?? btw, I'm using PB v2.1.
*****************************************
Dim form$(5) 'array to hold the arguments for the copy count from command line 'arg$(4)
DIM Arg$(5) 'Array to hold the arguments
MaxArg% = 5 'Maximum number of arguments
'
'defsng a-z
'*********process command line*********************************************
CLS
CALL ParCline(Arg$(), MaxArg%, Res%)
if arg$(1) = "" then
cls
Print "command Usage: 1042ro <IF> <OF> <LA> <CC> <B/S>
print " Where: <IF> is input data file"
print " Where: <OF> is new Output data file"
print " Where: <LA> is the Label (job name) for reports and label"
print " Where: <CC> is the Copy Count example: 'bc2'or 'd' for broker"
print " Where: <B/S> is the job a statement run or broker run"
print " Example: 1042ro part1.idx part1a.idx Fcl1099 bc2 S"
end 10
end if
test$ = dir$(arg$(1),16) 'test for exist of file shown on command line
if test$ = "" then
cls
print arg$(1);" 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
if arg$(3) = "" then
cls
print "Enter a valid Job name on the command line"
print "see help"
end 10
end if
if arg$(4) = "" then
print "enter a valid Copy Count"
end 10
end if
if arg$(5) = "" then
print "enter a valid Job type"
print "type 1099ro.exe without any arguments for help"
end 10
elseif instr(arg$(5), any "BSbs") = 0 then
print "Enter either a 'b' - broker or 's' - statement"
end 10
end if
mailflag = 0 'for mail/nomail cover sheets
RL = 625 'record length
'***************input values for tape and workorder**************
do
line input "Enter Workorder number: " workorder$
if len(ltrim$(rtrim$(workorder$))) = 7 then exit loop
print "Enter a 7 digit number"
loop
do
line input "Enter Tape number: " tapenumber$
if len(ltrim$(rtrim$(tapenumber$))) < 5 and ltrim$(rtrim$(tapenumber$)) <> "" then exit loop
print "Enter a valid tape number"
loop
'*************process copy count into a array to hold for later*******
'************the length is also used in the for loop to get mulitpy copies of a statement
'************this number/letter will be placed in the djde line****
cclengthof = len(arg$(4)) 'length of copy count variable
for t = 1 to cclengthof
form$(t) = mid$(ucase$(arg$(4)),t,1)
next t
'********open input and output files beginning processing******
open arg$(1) for binary lock read write as #1 len = 8192
open arg$(2) for output lock read write as #3
do
get$ #1,rl,idx$
if not eof(1) then
incr statements
'parse the index line into all necessary variables
code1$ = rtrim$(left$(idx$,2)) '5f
amount1$ = ltrim$(rtrim$(mid$(idx$,4,14))) '6f
amount2$ = ltrim$(rtrim$(mid$(idx$,18,14))) '8f
code2$ = rtrim$(mid$(idx$,34,3)) '9f
code3$ = rtrim$(mid$(idx$,39,2)) 'af
amount3$ = ltrim$(rtrim$(mid$(idx$,42,14))) 'bf
code4$ = rtrim$(mid$(idx$,58,2)) 'cf
code5$ = rtrim$(mid$(idx$,61,2)) 'df
amount4$ = ltrim$(rtrim$(mid$(idx$,64,14))) 'ef
amount5$ = ltrim$(rtrim$(mid$(idx$,79,14))) 'gf
code6$ = rtrim$(mid$(idx$,96,2)) 'hf
code7$ = rtrim$(mid$(idx$,100,2)) 'if
amount6$ = ltrim$(rtrim$(mid$(idx$,103,14))) 'jf
code8$ = rtrim$(mid$(idx$,119,2)) 'kf
amount7$ = ltrim$(rtrim$(mid$(idx$,122,14))) 'lf
amount8$ = ltrim$(rtrim$(mid$(idx$,137,14))) 'nf
amount9$ = ltrim$(rtrim$(mid$(idx$,152,14))) 'of
code9$ = rtrim$(mid$(idx$,168,2)) 'pf
ss$ = rtrim$(mid$(idx$,172,11)) 'tf
broker$ = rtrim$(mid$(idx$,185,14)) 'qf
brokercode$ = mid$(idx$,185,2) 'two character brokercode ex. 'IA'
coaddress1$ = rtrim$(mid$(idx$,201,31)) 'UE
coaddress2$ = rtrim$(mid$(idx$,233,31))
coaddress3$ = rtrim$(mid$(idx$,265,31))
coaddress4$ = rtrim$(mid$(idx$,297,31)) 'only get first 2 letters of broker number this is the broker code
accn1$ = rtrim$(mid$(idx$,329,10))'vf?
citycode$ = rtrim$(mid$(idx$,356,31))'wf?
primary1$ = rtrim$(mid$(idx$,392,31))'SE
primary2$ = rtrim$(mid$(idx$,424,31))
primary3$ = rtrim$(mid$(idx$,456,31))
primary4$ = rtrim$(mid$(idx$,488,31))
primary5$ = rtrim$(mid$(idx$,520,31))
primary6$ = rtrim$(mid$(idx$,552,31))
dpbc$ = rtrim$(mid$(idx$,597,12)) 'rf
mailcode$ = mid$(idx$,615,1)'determine mail or nomail
dpbccode$ = mid$(idx$,616,1)'determine of statements gets a dpbc
if mailcode$ = "1" then incr nomails
gosub buildoutputpage
else
exit loop
end if
loop until eof(1)
close
gosub outputreport
gosub label
gosub dplog
gosub writetape
end
$include "clinesub.bas"
'subroutine to build the output page
buildoutputpage:
'build cover sheets for both statements and brokers jobs
if ucase$(arg$(5)) = "S" then
'***************print cover pages for NO-Mail section and Mail section***
if mailcode$ = "1" and statements = 1 then 'no-mail statements only do it once
print #3," $DJDE$ FEED=AUX,FORMS=SLIP1,FORMAT=SLPPD1,END;"
print #3,"11 This is No-Mail Group"
elseif mailcode$ = "2" and mailflag = 0 then 'for mails only once set flag
print #3," $DJDE$ FEED=AUX,FORMS=SLIP1,FORMAT=SLPPD1,END;"
print #3,"11 This is Mailable Group"
mailflag = 1 'change flag so this prints only once
end if
elseif ucase$(arg$(5)) = "B" then
'************print cover pages for each branch of the broker job 'GX' must be
'************sorted by broker and branch beforehand
if brokercode$ <> savebrokercode$ then
print #3," $DJDE$ FEED=AUX,FORMS=SLIP1,FORMAT=SLPPD1,END;"
print #3,"11 This is the ";brokercode$;" Group"
savebrokercode$ = brokercode$
end if
end if
'okay this job gets multiply copies depending on the arg$(4) the copy count
'if the copy count is bc2 this is 3 copies so place in for loop
for x = 1 to cclengthof
incr pages 'count pages
'**********DJDE LINE*******
print #3," $DJDE$ FORMAT=1042S,FORMS=1042S";form$(x);",FEED=MAIN,END;"
rem ****inserter barcode and eyereadable*********
'if not mailcode$ = "1" and ucase$(arg$(5)) = "S" then 'no barcode for nomails or the broker job
if ucase$(arg$(5)) = "S" then 'no barcode for the broker job note there thousands of nomails alot of foreighn addresses
if statements < 10 then
print #3,"1A *"
print #3," A 0"
print #3," A ";ltrim$(str$(statements))
print #3," A ";ltrim$(str$(x))
if x = cclengthof then
print #3," A 1"
else
print #3," A 0"
end if
print #3," A 0"
print #3," A *"
elseif statements > 9 then
print #3,"1A *"
print #3," A ";left$(right$(ltrim$(str$(statements)),2),1)
print #3," A ";right$(right$(rtrim$(str$(statements)),2),1) 'uses pages count in
print #3," A ";ltrim$(str$(x))
if x = cclengthof then
print #3," A 1"
else
print #3," A 0"
end if
print #3," A 0"
print #3," A *"
end if
rem eye readable
if statements < 10 then
print #3,"2B *"
print #3," B 0"
print #3," B ";ltrim$(str$(statements))
print #3," B ";ltrim$(str$(x)) 'multipages based on code in index file mrl9002i.bas field - 134:2
if x = cclengthof then
print #3," B 1"
else
print #3," B 0"
end if
print #3," B 0" '21 - 2nd of 2 pages
print #3," B *"
elseif statements > 9 then
print #3,"2B *"
print #3," B ";left$(right$(ltrim$(str$(statements)),2),1)
print #3," B ";right$(right$(rtrim$(str$(statements)),2),1) 'uses pages count in
print #3," B ";ltrim$(str$(x)) 'barcode switch pages to string
if x = cclengthof then
print #3," B 1"
else
print #3," B 0"
end if
print #3," B 0" 'parse first 2 numbers from right side
print #3," B *" 'then parse first number from right side
end if
else
print #3,"1A"
print #3," A"
print #3," A"
print #3," A"
print #3," A"
print #3," A"
print #3," A"
print #3,"2B"
print #3," B"
print #3," B"
print #3," B" 'multipages based on code in index file mrl9002i.bas field - 134:2
print #3," B"
print #3," B" '21 - 2nd of 2 pages
print #3," B"
end if
'************control line after barcode in this particular case
if statements < 100 then
batchnumber$ = "0001-00"+ltrim$(right$(str$(statements),2))
else
group$ = str$((statements\100)+1)
batchnumber$ = group$+"-"+ltrim$(right$(str$(statements),2))
end if
print #3,"3C 1 ";pages;" ";statements;" ";workorder$;" ";batchnumber$
'REST OF THE REPORT
print #3,"4D "
print #3,"5F ";code1$
print #3,"6F ";amount1$
print #3,"7F "
print #3,"8F ";amount2$
print #3,"9F ";code2$
print #3,"AF ";code3$
print #3,"BF ";amount3$
print #3,"CF ";code4$
print #3,"DF ";code5$
print #3,"EF ";amount4$
print #3,"FF "
print #3,"GF ";amount5$
print #3,"HF ";code6$
print #3,"IF ";code7$
print #3,"JF ";amount6$
print #3,"KF ";code8$
print #3,"LF ";amount7$
print #3,"MF "
print #3,"NF ";amount8$
print #3,"OF ";amount9$
print #3,"PF ";code9$
print #3,"QF ";broker$
if dpbccode$ = "2" and ucase$(arg$(5)) = "S" and x = 1 then 'no dpbc for broker job or on the 2nd and 3rd pages
print #3,"RF *";dpbc$;"*"
else
print #3,"RF"
end if
print #3,"SE ";primary1$
print #3," E ";primary2$
print #3," E ";primary3$
print #3," E ";primary4$
print #3," E ";primary5$
print #3," E ";primary6$
print #3,"SE ";primary1$
print #3," E ";primary2$
print #3," E ";primary3$
print #3," E ";primary4$
print #3," E ";primary5$
print #3," E ";primary6$
print #3,"TF ";ss$
print #3,"UE ";coaddress1$
print #3," E ";coaddress2$
print #3," E ";coaddress3$
print #3," E ";coaddress4$
print #3,"UE ";coaddress1$
print #3," E ";coaddress2$
print #3," E ";coaddress3$
print #3," E ";coaddress4$
print #3,"VF ";accn1$
print #3,"WF ";citycode$
print #3,"XF "
print #3,"YF "
print #3,"ZF "
print #3,"ZE "
print #3," E "
print #3," E "
print #3," E "
print #3," E "
next x
return
'***build tapel label*****
label:
open "label.txt" for output as #1
print #1,arg$(3);" ";workorder$;" ";tapenumber$
print #1,date$;" ";time$;" copies: ";arg$(4);" 1 of 1"
print #1,"statements\pages = ";statements;"\";pages
for x = 1 to 6
print #1,
next x
close #1
return
'***build dplog string*******
dplog:
open "dplog.txt" for output as #1
print #1,date$;" ";time$;" ";arg$(3);" ";workorder$;" ";tapenumber$;" statements\pages = ";statements;"\";pages
close #1
return
'output report
outputreport:
if ucase$(arg$(5)) = "S" then
filesuf$ = left$(arg$(3),3)+"1042r"+".rpt"
else
filesuf$ = left$(arg$(3),3)+"brok"+".rpt"
end if
open filesuf$ for output as #1
if ucase$(arg$(5)) = "S" then
print #1,"Statement job: ";arg$(3)
else
print #1," Broker Job: ";arg$(3)
end if
print #1,"Workorder: ";workorder$;" Tape Number: ";tapenumber$;" ";date$;" ";time$
print #1,"The Copies are: ";ucase$(arg$(4))
print #1,"total No-mails: ";nomails
print #1,"Total Statements: ";statements
print #1," Total Pages: ";pages
close
return
'**********Write the Output file to a Tape using a external Program called
'**********d2twc.exe "Must be in the Path"*********
writetape:
print "Do you Wish to Write the output file to a tape [y/n]"
s$ = input$(1)
if s$ = "y" then
do
print "Enter Tape Drive number [0/2/3]"
t$ = input$(1)
if t$ = "0" or t$ = "2" or t$ = "3" then exit loop
loop
tapedrive$ = "tape"+t$
runjob$ = "d2twc "+tapedrive$+" "+arg$(2)+" 1" 'arg$(2) is the output data file name
execute runjob$
end if
return
------------------
Tags: None
Leave a comment: