LB Booster
« retrieving record »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:03am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: retrieving record  (Read 221 times)
hammerjit
New Member
Image


member is offline

Avatar




PM


Posts: 26
xx 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 » User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx 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 
User IP Logged

hammerjit
New Member
Image


member is offline

Avatar




PM


Posts: 26
xx 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. grin
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls