Jump to content
Sign in to follow this  
w1k

TB question

Recommended Posts

hello,

i have code which open and place text on screen:

 

10 OPEN #1,4,0,"D:filename.ext"
20 TRAP#ERR:CLS
30 DO
40   GET #1,BYTE:? CHR$(27);CHR$(BYTE);
50 LOOP
60 #ERR
70 CLOSE #1

 

how i can:

1. make menu selection, like:

A....readme

B....whats new

etc..

if i press A, then readme.txt load..

 

2. continual reading

if screen is full of text, i can use GET KEY for next part, but how?

Share this post


Link to post
Share on other sites

1. try this simple way of menu:

 

80 GET E:REM wait for key
90 IF E=ASC("A") THEN ... do something
100 IF E=ASC("B") THEN ... do something else ...
... and so on ...

 

2. you can watch the cursor-position by looking at memory-cell 85:

 

IF PEEK(85)>22 THEN GET E:CLS:REM wait for key, if cursur in the line under line 22, then clear the screen

 

this is a very easy way, it clears the screen and starts from the top of the screen again.

Share this post


Link to post
Share on other sites

ok, i have menu:

atari000.png

 

how i put together with opening/reading txt files?

Edited by w1k

Share this post


Link to post
Share on other sites

just change the line-numbers of the text-reading-code below, and merge both to one program.

 

e.g.:

170 IF E=ASC("B") THEN EXEC READ_TEXT
180 GOTO 70
500 PROC READ_TEXT
510 OPEN #1,4,0,"D:filename.ext"
520 TRAP 560:CLS
530 DO
540   GET #1,BYTE:? CHR$(27);CHR$(BYTE);
550 LOOP
560 REM
570 CLOSE #1
599 ENDPROC

Share this post


Link to post
Share on other sites

just change the line-numbers of the text-reading-code below, and merge both to one program.

 

e.g.:

170 IF E=ASC("B") THEN EXEC READ_TEXT
180 GOTO 70
500 PROC READ_TEXT
510 OPEN #1,4,0,"D:filename.ext"
520 TRAP 560:CLS
530 DO
540   GET #1,BYTE:? CHR$(27);CHR$(BYTE);
550 LOOP
560 REM
570 CLOSE #1
599 ENDPROC

 

ok, thank you, i try it..

and what can i do if i can read/view more files? A,B,C,D options?

Share this post


Link to post
Share on other sites

just change the line-numbers of the text-reading-code below, and merge both to one program.

 

e.g.:

170 IF E=ASC("B") THEN EXEC READ_TEXT
180 GOTO 70
500 PROC READ_TEXT
510 OPEN #1,4,0,"D:filename.ext"
520 TRAP 560:CLS
530 DO
540   GET #1,BYTE:? CHR$(27);CHR$(BYTE);
550 LOOP
560 REM
570 CLOSE #1
599 ENDPROC

 

 

ERROR- 129 IS OPEN AT LINE 510

The error I had previously

Share this post


Link to post
Share on other sites

just change the line-numbers of the text-reading-code below, and merge both to one program.

 

e.g.:

170 IF E=ASC("B") THEN EXEC READ_TEXT
180 GOTO 70
500 PROC READ_TEXT
510 OPEN #1,4,0,"D:filename.ext"
520 TRAP 560:CLS
530 DO
540 GET #1,BYTE:? CHR$(27);CHR$(BYTE);
550 LOOP
560 REM
570 CLOSE #1
599 ENDPROC

 

 

ERROR- 129 IS OPEN AT LINE 510

The error I had previously

 

Tha's because channel #1 is opened in 2 different places - once to the K:eyboard and once to the D:filename.ext. Change one of the to channel #2 or make sure sure close the K: before opening the D:.

Share this post


Link to post
Share on other sites

with TB the keyboard is open just use a GET K:PUT K. also OPEN #1 should usually be prefixed with CLOSE #1:OPEN #1 this prevent many of this type of ERR.

Share this post


Link to post
Share on other sites

so.. i must use GET K for keyboard? ok, i look to the literature..

ok, now its work fine, i have last questions.

 

-what can i do with error- 136 ? end file EOF?

-how work GET K?

if i try i, program cycle..

-what about o long txt files?

-and what about more txt files? A,B,C,D options..?

 

 

thank you

Edited by w1k

Share this post


Link to post
Share on other sites

IF ERR=136:do what ever you want (i,e..) END RUN GOTO STOP :ENDIF

 

this should be placed where your TRAP #ERR sends:

 

200 #ERR

210 IF ERR=136

 

also ERR is a reserved word with TB...

Share this post


Link to post
Share on other sites

 

 

-how work GET K?

if i try i, program cycle..

-what about o long txt files?

-and what about more txt files? A,B,C,D options..?

 

 

thank you

 

10 DIM A$(19)

.

. MENU

. A

. B

. C

. D

. E

. GET K

. IF K=65:A$="D:A FILENAME.XXX":ENDIF

. IF K=66:A$="D:B FILENAME.XXX":ENDIF

. IF K=67:A$="D:C FILENAME.XXX":ENDIF

. ETC.....

 

 

GET just scans the keyboard key presses and returns the key pressed.

Share this post


Link to post
Share on other sites

ok, it's working now :)

now i must fix that 136 error..

thank you for your patience

Edited by w1k

Share this post


Link to post
Share on other sites

what can be first? menu or loading/viewing files?

i have first menu and then..

DIM $A(19)

IF K=64:A$="FILE1.TXT":ENDIF

IF K=65:A$="FILE1.TXT2":ENDIF

OPEN #1,4,0,A$

DO

GET #1,BYTE...

CLOSE #1

 

ERROR -130

 

 

DIM $A(19)

.

. MENU

.

GET K

IF K=64:A$="D:FILE1.TXT":ENDIF

IF K=65:A$="D:FILE1.TXT2":ENDIF

OPEN #1,4,0,A$

DO

GET #1,BYTE...

CLOSE #1

 

are you using SD 90k ATR or DD with 65535K ATR.

sio2sd

sio2pc

Share this post


Link to post
Share on other sites

Well,

 

I am always using the lamer way to write a basic menu:

 

10 CLR: GRAPHICS 18 (alternatively: ? CHR$(125) or ? "ESC, CTRL+CLR")

20 POSITION ...: ? #6;"(Menu name, e.g. Tetris Clones)"

30 POSITION ...: ? #6;"----------------------"

40 POSITION ...: ? #6;"A) tetris 1"

50 POSITION ...: ? #6;"B) tetris 2"

60 POSITION ...: ? #6;"C) tetris 3"

70 POSITION ...: ? #6;"D) tetris 4"

120 CLOSE #3:OPEN #3,4,0,"K:":GET #3,K

130 IF K=ASC("A") THEN RUN"D:TETRIS1.BAS"

140 IF K=ASC("B") THEN RUN"D:TETRIS2.BAS"

150 IF K=ASC("C") THEN RUN"D:TETRIS3.BAS"

160 IF K=ASC("D") THEN RUN"D:TETRIS4.BAS"

 

This stupid menu works in TB XL as well as in Atari Basic and I can always modify it the way I wish (change menu name and/or program names). And err, I never need to remember or look-up the values for A, B, C, D,... in upper or lower case. Yes, stupid+lame menu, but works for me... -Andreas Koch.

Edited by CharlieChaplin

Share this post


Link to post
Share on other sites

thank you, yesterday i finnished them.. next problem is viewing files (its working, but buggy)

Share this post


Link to post
Share on other sites

thank you, yesterday i finnished them.. next problem is viewing files (its working, but buggy)

 

Viewing files ... hmm

 

First of all you need a textfile, then open it and get the bytes till you reach eof. The bytes you got, should be sent thru S: or E: (depending on the format - screen or atasci). That should be all.

Share this post


Link to post
Share on other sites

and what about a looong text? i need stop text if screen is full and if i press key, text will be continue..

 

atari001.png

 

loading txt files start at 5030

Edited by w1k

Share this post


Link to post
Share on other sites

2. you can watch the cursor-position by looking at memory-cell 85:

 

IF PEEK(85)>22 THEN GET E:CLS:REM wait for key, if cursur in the line under line 22, then clear the screen

 

this is a very easy way, it clears the screen and starts from the top of the screen again.

 

This is from Post #2 in this thread.

Share this post


Link to post
Share on other sites

2. you can watch the cursor-position by looking at memory-cell 85:

 

IF PEEK(85)>22 THEN GET E:CLS:REM wait for key, if cursur in the line under line 22, then clear the screen

 

this is a very easy way, it clears the screen and starts from the top of the screen again.

 

This is from Post #2 in this thread.

 

it doesnt work.. i put it on line 5065..

 

? peek(82)

0

Edited by w1k

Share this post


Link to post
Share on other sites

Try this ATR:

 

MdosTB2.atr

 

This is a MyDos 90k atr. It boots to TB and opens FILE autorun.bas and then opens text files for viewing.

 

Modify with your title and your text files, I put a few text files on the atr for TB instructions.

 

This has full MyDOS so you can get back to the dos menu.

 

Good Luck...icon_ponder.gif

Share this post


Link to post
Share on other sites

woooww.. looks nice.. im go study it.. thank you

-hmm.. maybe im stupid if i cant make something simply like this.

 

fuuh.. it's to hard, im stupid.. so

Edited by w1k

Share this post


Link to post
Share on other sites

Hi w1k,

 

Larger atr's are more fun for me to work with because of OPTION 'Q' make directory. You can put games in one FOLDER, basic files in another FOLDER, text files TEXT, etc.. I usually name FOLDERS with 4 characters (i.e) XXXX so they are easier to type and don't over flow the [PATH] if getting filename.

The previous posts and the AUTORUN.BAS file is modified from the HSC Bonus Round's "Best of Basic" ATR and another code snippet I got here on AtariAge some time ago.

Share this post


Link to post
Share on other sites

atari002.png

 

something wrong? :)

if pressed A- ERROR 135 RD ONLY at 5060

if pressed B- ERROR 136 EOF at 5060

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...