Liberty BASIC Community Forum
« Input past file error »

Welcome Guest. Please Login or Register.
Feb 18th, 2018, 3:40pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Input past file error  (Read 98 times)
TexasPete
Full Member
ImageImageImage


member is offline

Avatar

Persistance Pays


Homepage PM

Gender: Male
Posts: 122
xx Input past file error
« Thread started on: Jan 17th, 2018, 10:41am »

I am getting back into lb for a project. I have been translating some old code to lb. I am getting an input past file error on the read. Below is the code . I am sure it is something simple if any one can catch my error I would appreciate it. Thanks

Texas Pete
[WRITESETUPFILE]
F$ = "SETUP.dat"
OPEN F$ FOR OUTPUT AS #1
PRINT #1, N1$
PRINT #1, N2$
PRINT #1, N3$
PRINT #1, N4$
PRINT #1, DG$
PRINT #1, PT$
PRINT #1, DF$
PRINT #1, PR1$
PRINT #1, PR2$
PRINT #1, INTEREST$
PRINT #1, F$
PRINT #1, REC$
PRINT #1, MAXSTOPS$
CLOSE #1
REC= val(REC$)
MAXSTOPS=val(MAXSTOPS$)
return
'==================================================================
[READSETUPFILE]
F$ = "SETUP.dat"
OPEN F$ FOR INPUT AS #1
INPUT #1, N1$
INPUT #1, N2$
INPUT #1, N3$
INPUT #1, N4$
INPUT #1, DG$
INPUT #1, PT$
INPUT #1, DF$
INPUT #1, PR1$
INPUT #1, PR2$
INPUT #1, INTEREST$
INPUT #1, F$
INPUT #1, REC$
INPUT #1, MAXSTOPS$
CLOSE #1
REC= val(REC$)
MAXSTOPS=val(MAXSTOPS$)
return



User IP Logged

Tree Doctor Houston http:// www.treecare.tv/
Pest Control The Woodlands http://www.treecare.tv/housepests.html
robmcal
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 401
xx Re: Input past file error
« Reply #1 on: Jan 17th, 2018, 11:45am »

Your posted code seems fine. Are you sure you are properly creating the file before reading it?
User IP Logged

Definition of an Upgrade: Take old bugs out, put new ones in.
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1182
xx Re: Input past file error
« Reply #2 on: Jan 17th, 2018, 12:12pm »

Code works fine if you rem out the returns...
I added lines to initialise the variables..
Code:
N1$ ="nOne"
N2$ ="nTwo"
N3$ ="nThree"
N4$ ="nFour"
DG$ ="dG"
PT$ ="pT"
DF$ ="dF"
PR1$ ="prOne"
PR2$ ="prTwo"
INTEREST$ ="interest"
F$   ="eff"
REC$ ="rec"
MAXSTOPS$ ="maxStop"

F$ = "SETUP.dat"
OPEN F$ FOR OUTPUT AS #1
#1 N1$
#1 N2$
#1 N3$
#1 N4$
#1 DG$
#1 PT$
#1 DF$
#1 PR1$
#1 PR2$
#1 INTEREST$
#1 F$
#1 REC$
#1 MAXSTOPS$
CLOSE #1

REC      = val( REC$)
MAXSTOPS =val( MAXSTOPS$)
'return
'==================================================================
[READSETUPFILE]
F$ = "SETUP.dat"
OPEN F$ FOR INPUT AS #1
INPUT #1, N1$
INPUT #1, N2$
INPUT #1, N3$
INPUT #1, N4$
INPUT #1, DG$
INPUT #1, PT$
INPUT #1, DF$
INPUT #1, PR1$
INPUT #1, PR2$
INPUT #1, INTEREST$
INPUT #1, F$
INPUT #1, REC$
INPUT #1, MAXSTOPS$
CLOSE #1
REC       = val( REC$)
MAXSTOPS  =val( MAXSTOPS$)
'return
 

NB You may get into trouble using F$ as a variable and as the filename. Did you intend that??
« Last Edit: Jan 17th, 2018, 12:13pm by tenochtitlanuk » User IP Logged

TexasPete
Full Member
ImageImageImage


member is offline

Avatar

Persistance Pays


Homepage PM

Gender: Male
Posts: 122
xx Re: Input past file error
« Reply #3 on: Jan 18th, 2018, 08:32am »

Thanks All.
I think I needed to initialize the variables by filling the variables in and writing, that seems to have solved the problem.

Texas Pete
User IP Logged

Tree Doctor Houston http:// www.treecare.tv/
Pest Control The Woodlands http://www.treecare.tv/housepests.html
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls