Jump to content
IGNORED

separate text at end of line


w1k

Recommended Posts

A bit of fancy programming...

 

check for word overflow - if last character of a line and first chr of the next line is alpha, then you'd want to truncate the line backwards from there so the last character printed is a SPACE or punctuation mark.

 

You could probably do it by just making a few pointer variables into the string. Use loops to do the character scanning. Or does Turbo-Basic have some sort of INSTR() function.

Link to comment
Share on other sites

A bit of fancy programming...

 

check for word overflow - if last character of a line and first chr of the next line is alpha, then you'd want to truncate the line backwards from there so the last character printed is a SPACE or punctuation mark.

 

You could probably do it by just making a few pointer variables into the string. Use loops to do the character scanning. Or does Turbo-Basic have some sort of INSTR() function.

 

some little hint or example? im poor programmer

Link to comment
Share on other sites

I dunno what "tBasic" is, but you'd just fetch each character out of the file and build a temp string (WORD$) until the space character is encountered. Then, check the current column plus the length of the word against the maximum columns (40). If > 0, print the word on the current line (or else, print a carriage return).

 

I'm too lazy to look up the correct PEEK location for line 333, but I think that it would go something like this:

 

330 TRAP 340
331 GET #2,A
332 IF A <> 32 THEN WORD$(LEN(WORD$)+1)=CHR$(A):GOTO 331
333 IF 40-PEEK(91)+LEN(WORD$)>0 THEN 335
334 ?#3:GOTO 336:REM end current line
335 ?#3;CHR$(32);:REM continue current line
336 ?#3;WORD$;:WORD$="":REM print the word and clear WORD$
337 GOTO 331

Edited by Nukey Shay
Link to comment
Share on other sites

I said the PEEK location might be incorrect ;)

This test program worked fine in regular Atari Basic. It's basically the same as the above, but with line 333 altered a bit.

 

10 DIM WORD$(255)
20 POKE 752,1
30 POKE 82,0
40 OPEN #2,4,0,"D:TEXTFILE"
330 TRAP 340
331 GET #2,A
332 IF A<>32 THEN WORD$(LEN(WORD$)+1)=CHR$(A):GOTO331
333 IF 39-(PEEK(99)+LEN(WORD$))>0 THEN 335
334 ?:GOTO336
335 ?" ";
336 ?WORD$;:WORD$=""
337 GOTO 331
340 CLOSE #2

Link to comment
Share on other sites

This effort might be a little easier but similar to the code you are using..and will stop when screen fills to 22 lines.

 

10 REM ALL TEXT MUST BE ENDED WITH THE RETURN KEY ON EACH <40 CHARACTER LINE.
100 DIM A$(44):GRAPHICS 0:POKE 82,0:? "}"
110 ? ,"A=READ - FIRST.TXT"
120 ? ,"B=READ - SECOND.TXT"
130 ? ,"C=READ - THIRD.TXT"
140 POKE 764,255:IF PEEK(764)=255:GOTO 140:ENDIF 
145 ? "}":REM CLEAR SCREEN
150 IF PEEK(764)=63:A$="D:FIRST.TXT":ENDIF 
160 IF PEEK(764)=21:A$="D:SECOND.TXT":ENDIF 
170 IF PEEK(764)=18:A$="D:THIRD.TXT":ENDIF 
200 TRAP 250:OPEN #1,4,0,A$
210 INPUT #1,A$ A$:IF PEEK(84)<22:GOTO 210:ENDIF 
220 POKE 764,255:? "PRESS KEY FOR MORE"
230 IF PEEK(764)=255 THEN 230
240 POKE 764,255:? "}":GOTO 210
250 CLOSE #1:POKE 764,255:CLR :POKE 82,2:END 

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...