Author |
Topic: retrieving record (Read 221 times) |
|
hammerjit
New Member
member is offline
Posts: 26
|
|
retrieving record
« Thread started on: Jun 30th, 2015, 08:15am » |
|
hi...my assignment is to retrieve record from a text file and print out result
this is my sample text file Start, 0, 0, 0, 0 Transfer, 1, 20-05-15, Transfer to Bank, 722 Transfer, 2, 22-05-15, Transfer to Bank, 53855 Transfer, 3, 23-05-15, Transfer to Bank, 149500 Payment, 4, 23-05-15, Advance Out, 19500 Payment, 5, 24-05-15, Advance Out, 2718 Payment, 6, 24-05-15, Advance Out, 3688 Payment, 7, 24-05-15, Advance Out, 501 Transfer, 8, 25-05-15, Transfer to Bank, 134200 Transfer, 10, 23-05-15, Transfer to Bank, 19501
my code will ask for which record to print (which is the second field in each line)
Code:
input "Please enter the record to print : " ; Seqno$
OPEN "c:\coupons2015.txt" FOR INPUT AS #f
search$=Seqno$
while eof(#f)=0
line input #f,l$
if word$(l$,2,",")=search$ then
input1$ = (word$(l$,1,",")):input2$ = (word$(l$,3,",")):input3$ = (word$(l$,4,",")):input4$ = (word$(l$,5,",")):input5$ = (word$(l$,6,",")):input6$ = (word$(l$,7,","))
end if
wend
close #f
print input1$,input2$,input3$,input4$,input5$,input6$,input7$
|
« Last Edit: Jun 30th, 2015, 08:15am by hammerjit » |
Logged
|
|
|
|
tsh73
Full Member
member is offline
Gender:
Posts: 210
|
|
Re: retrieving record
« Reply #1 on: Jun 30th, 2015, 11:41am » |
|
I think you forgot to ask question.
But just in case, your "word$" return part of string between delimiters. That is, ' 2' (with space attached). Add trim$: Code:if trim$(word$(l$,2,","))=trim$(search$) then
|
|
Logged
|
|
|
|
hammerjit
New Member
member is offline
Posts: 26
|
|
Re: retrieving record
« Reply #2 on: Jul 1st, 2015, 02:12am » |
|
lol....ya i forgot to ask the question but thanks tsh73 for your help.
|
|
Logged
|
|
|
|
|