im trying to replace a phc table with information from a txtfile but im not getting the information on the screen.
re is the table i want to replace the values txtcabecalho is the imported file that people have to choose reciboc is the cursor that i've created to store the values from the txt file so i can replace them on re and show them to the screen sre is the screen of the table re.
Local txtcabecalho
Use re
Delete all
txtcabecalho=getfile("txt")
Create cursor reciboc(rno n(10), rdata d(10), moeda c(3), no n(10), nome c(2), ccusto c(20), intid c(10), clbanco c(20), total float(19), totalmoeda float(19), ndoc n(3))
append from (txtcabecalho) delimited with tab
select reciboc
goto top
scan for !empty(reciboc.rno)
select re
append blank
replace re.rno with reciboc.rno
replace re.rdata with reciboc.rdata
replace re.moeda with reciboc.moeda
replace re.no with reciboc.no
replace re.nome with reciboc.nome
replace re.ccusto with reciboc.ccusto
replace re.intid with reciboc.intid
replace re.clbanco with reciboc.clbanco
replace re.total with reciboc.total
replace re.totalmoeda with reciboc.totalmoeda
replace re.ndoc with reciboc.ndoc
select re
endscan
sre.refresh()
Thanks!
Updated
So this actually works if i crate a file of my own with the delimitianion i choose for example with tabs. Thi thing is the files that i need to import are like using spaces as spaceholders and got no delimitations from each other. Let me explain better. for example first 3 fields rno and rdata and moeda.
The txt files come like 22014-12-23EUR
Where 2 is the rno but has 9 spaces behind working like place holders for bigger numbers making the rno(10) Next is 2014-12-23 wich is right next to the rno with no delimitation wich does the rdata(10) Next is the moeda wich is EUR , again with no delimitation , being the moeda(3)
Many fields will be blank , and those the txt files come with spaces ocupying full length of the fields. Basically, field length is used as delimitation, and when empty , its filled with spaces.
Did u understood right? sorry im not an english native.
update
heres is some of the txt file 22014-11-27EUR 208 799,00 799,00 00
just keep in mind that before the first number 2 , there are 9 spaces. Thanks!
the rdata field wich is going to be filled with 2014-11-27 is rdata d(10)
edited
currently code:
Local txtcabecalho, fileconvert
Use re
zap
txtcabecalho=getfile("txt")
Create cursor reciboc(rno n(10), rdata d(10), moeda c(3), no n(10), nome c(2), ccusto c(20), intid c(10), gg c(20), chq c(20), clbanco c(20), total float(19), totalmoeda float(19), ndoc n(3))
fileconvert = filetostr(txtcabecalho)
chrtran(fileconvert,'-','')
strtofile(fileconvert, txtcabecalho)
append from (txtcabecalho) type sdf
scan
select re
append blank
replace rno with reciboc.rno
replace rdata with reciboc.rdata
replace moeda with reciboc.moeda
replace no with reciboc.no
replace nome with reciboc.nome
replace ccusto with reciboc.ccusto
replace intid with reciboc.intid
replace clbanco with reciboc.clbanco
replace total with reciboc.total
replace totalmoeda with reciboc.totalmoeda
replace ndoc with reciboc.ndoc
select re
endscan
select reciboc
browse title "resultado"
reindex
sre.refresh()
what i get is this is what i get
stil ltrying to figure out i really don't know aff
for example : firt row should be:
RNO 2 RDATA 2014-11-27 NO 208
EDITED
actually this made it ahah
fileconvert = filetostr(txtcabecalho)
fileconvert2 = strtran(fileconvert,'-','')
strtofile(fileconvert2, txtcabecalho)
if i need further help i'll update my question! Thank you so much guys!
EDITED
Doyou guys know if there is any problem converting from txt file float numbers to cursors?
I got for example 799,20 but i just show up as 799. Data type is set to totalmoeda f(19) . This must be pretty simple but i can't find it!