Liberty BASIC Community Forum
« Can't see the error in Random Access code. »

Welcome Guest. Please Login or Register.
Nov 24th, 2017, 10:52am


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


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Can't see the error in Random Access code.  (Read 239 times)
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Can't see the error in Random Access code.
« Thread started on: Aug 10th, 2016, 09:57am »

20 open "myrandomfile.dat" for Random as #1 LEN = 65
Field #1, 20 as name$, 25 as street$, 20 as town$
close #1

30 input "Geben Sie einen Namen fuer Feld 1 ein : " ; name$
40 input "Geben Sie eine Strasse mit Hausnummer fuer Feld 2 ein: " ; street$
50 input "Geben Sie eine Stadt fuer Feld 3 ein: " ; town$

30 open "myrandomfile.dat" for Random as #1 Len = 65
Field #1 , 20 as name$, 25 as street$, 20 as town$
Put #1, 1
close #1


Hi there ,
in this simple code is a error message that there are
multiple Label definitions of the label #1.

I cannot see a multiple definition. Do you see it ?

WBR

Zabo

User IP Logged

Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2285
xx Re: Can't see the error in Random Access code.
« Reply #1 on: Aug 10th, 2016, 10:15am »

You have two lines that start with 30. Those are being interpreted as line labels, and because there's two of them, it's a duplicate label definition error.
« Last Edit: Aug 10th, 2016, 10:15am by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: Can't see the error in Random Access code.
« Reply #2 on: Aug 10th, 2016, 10:27am »

Thank you Chris ,

i am a little overworked here.

Less sleep.


Zabo
User IP Logged

Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: Can't see the error in Random Access code.
« Reply #3 on: Aug 10th, 2016, 11:09am »

Hi Chris ,

this Random Input Loop works.

200 open "myrandomfile.dat" for Random as #1 Len = 65
Field #1 , 20 as name$, 25 as street$, 20 as town$
210 FileLength = LOF(#1) / 65 'Ermittlung der vorhandenen Records
220 x = FileLength + 1
230 input "Geben Sie einen Namen fuer Feld " ; x ; " ein : " ; name$
240 input "Geben Sie eine Strasse mit Hausnummer fuer Feld " ; x ; " ein: " ; street$
250 input "Geben Sie eine Stadt fuer Feld " ; x ; " ein: " ; town$
260 Put #1, x
270 Input "Wollen Sie einen weiteren Datansatz eingeben J/N ?" ; neuersatz$
280 if neuersatz$ = "J" or neuersatz$ = "j" then goto 210
290 if neuersatz$ = "N" or neuersatz$ = "n" then close #1
User IP Logged

Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: Can't see the error in Random Access code.
« Reply #4 on: Aug 10th, 2016, 11:18am »

Oh sorry , i forget one line for error handling.

here

300 if neuersatz$ <> "J" and neuersatz$ <> "j" and neuersatz$ <> "N" and neuersatz$ <> "n" then goto 270


See you....
User IP Logged

MKnarr
Senior Member
ImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 431
xx Re: Can't see the error in Random Access code.
« Reply #5 on: Aug 10th, 2016, 5:16pm »

For the record you can refield an ROF file' For example, you can change the field statement to:

Code:
Field #1 , 20 as name$, 45 as a$  


When you sort an array you need one less element.

Also change line :

Code:
30 open "myrandomfile.dat" for Random as #1 Len = 65 


to
Code:
60 open "myrandomfile.dat" for Random as #1 Len = 65 


If you are going to use line numbers, you can't use the same one twice.
« Last Edit: Aug 10th, 2016, 5:17pm by MKnarr » User IP Logged

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