explode "x,y","a,b","m,n" (Documentation Bugs and Problems)

by DickStomp ⌂ @, Europe Netherlands Sassenheim, Wednesday, October 08, 2014, 15:16 (902 days ago) @ DickStomp

#FIXED!! explode-bank.kbs

# processing bank records
# repair of inserted commas in a string, which is unstringed bij commas
# converting amount$ to signed using debcred$

name$ = "Name"
account$ = "123456789"
amount$ = "1234,56"
debcred$ = "D"
reason$ = "reason, you know"
address$ = "myaddress city"

# construct a bank record
bank$ = chr(34)+name$+chr(34)+","+chr(34)+account$+chr(34)+","
bank$ = bank$ +chr(34)+amount$+chr(34)+","+chr(34)+debcred$+chr(34)+","
bank$ = bank$ +chr(34)+reason$+chr(34)+","+chr(34)+address$+chr(34)

print "show bank-record"
print bank$

print "show work of explode an CSV-record"
field$ = explode(bank$, ",")
tmax = field$[?] -1
for t = 0 to tmax
print t+" "+field$[t]
next t
# sign amount
if mid(field$[4], 2, 1) = "D" then
L = length(field$[2])
field$[2] = chr(34) +"-"+ mid(field$[2], 2, L-1)
# shift left
for t = 4 to tmax-1
field$[t] = field$[t+1]
next t
tmax = tmax - 1
end if

print "repair hidden error commas"
dim new$(tmax)
new = 0
old = 0
for old = 0 to tmax
new$[new] = field$[old]
if right(field$[old],1) <> chr(34) then
new$[new] = new$[new] +","+ field$[old+1]
old = old + 1
tmax = tmax -1
end if
new = new + 1
next old

print "show new result"
for t = 0 to new-1
print t+" "+new$[t]
next t
end

--
it must be possible...


Complete thread:

 RSS Feed of thread

powered by my little forum