Jump to content
IGNORED

print at position in basic - is there an easier way?


seanlanefuller

Recommended Posts

I have a simple setup with a TI-99/4a and regular basic, no disk, no expanded memory, and save programs out the cassette port to another computer running sound recorder. I was trying to print a string at a location on the screen. A lot of BASIC interpreters have a print at command. I couldn't find one on the TI, so what I did was load a string variable, and an x and y, then call a subroutine that chops up the string and writes to the screen using a call hchar. Is there an easier way to do this?

Link to comment
Share on other sites

BTW, it is something like:

 

10 a$="Hello, World!"

20 l=14

30 x=10

40 y=10

50 gosub 1000

100 goto 100

1000 for i=1 to l

1010 call hchar(y,x,asc(seg$(a$,i,1)))

1020 next i

1030 return

 

I'd add...

 

05 CALL CLEAR

1011 X=X+1

1012 IF X=23 THEN 1040 ELSE 1020

1040 END

 

As for doing it any better... beats me!

Link to comment
Share on other sites

I was trying to print a string at a location on the screen. A lot of BASIC interpreters have a print at command. I couldn't find one on the TI, so what I did was load a string variable, and an x and y, then call a subroutine that chops up the string and writes to the screen using a call hchar. Is there an easier way to do this?[/size]

There's a few tricks in certain situations, but otherwise I think, no. That's the way it's been done in many TI Basic programs.

 

One trick when setting a score to it's initial value of 00000 is of course to use HCHAR and have the character 0 repeat within that one statement. Saving perhaps one second.

 

Another trick. If you have a screen full of info you want to print instantly instead of rolling up, you could set the background color to black, having all characters with the default color of black on transparent, PRINT what you want, and let it scroll up. Then turn on a background color (anything but black (or transparent)) - a screen full of text in a flash.

 

Also noting that the length of your message is 13 and not 14. One way to get the length of the string is like,

 

20 l=len(a$)

 

One funny thing I ran into just now ...

 

I took your program with the changes suggested by Omega.

 

However, try this

 

20 L=56

1001 PRINT I

 

I've capitalized, not to confuse with any other characters.

 

Now if I run it, it seems to break out with no warning or nothing ?!??!

 

tibasic.gif

Edited by sometimes99er
Link to comment
Share on other sites

Thanks everybody! It is weird to me just how slow and limited TI basic seems. That is one of the things that is cool about it I think. That was a cool animated screen capture River Patroller. How did you do that? I did use the L=LEN(A$) in the real program and it works great. I love the feeling of the program model in my head that working on the TI forces. I get a stronger feeling of this when I try to write code for the Tandy PC-1, PC-3, and PC-8 I have. It reminds me of my early days in college writing code using a DECWriter printing terminal. The pocket computers only show 1 line at a time. I feel like it makes me think harder. Like when I take a Google it break and make myself remember something rather than Googling it. Also, River, the idea of printing black on black and then switching the color map sounds pretty cool. I'm going to try that one out. I love learning cool tricks like that.

Link to comment
Share on other sites

It is weird to me just how slow and limited TI basic seems.

Yep, many benchmarks back then (1983) puts the TI-99/4A Basic in the very slow end. :(

 

Graphics and sounds (1979) seems a bit more accessible or nicely wrapped for the beginner. :)

 

One have to remember that the TI is actually a 1979 machine, but often people compare it with the C64 (1982), Spectrum (1982), MSX (1983) etc. However the TI caught on in 1983, when it became cheaper (and unprofitable) and then soon abandoned (by TI). I guess the competition was real. Was it head-to-head with Vic-20 in the states, and more Spectrum (the cheaper solution) and C64 in Europe ?

 

The bare console (TI), compared to most computers of the day (1983), did not have ability to peek, poke and run machine code. Sure you could fork out and spend money, but only relatively few bought the Mini Memory Module, or the E/A (Editor/Assembler cartridge) and started populating the Sherman tank (Peripheral Expansion Box).

 

I guess quite a few would-be geeks saved money for something else. :skull:

 

I had a few other machines and others I dreamt about. In the end, the TI-99/4A was kind of cool, different and in some ways first love, - to me Mini Memory saved it for a while.

 

That was a cool animated screen capture River Patroller. How did you do that?

"River Patroller" is a AtariAge generated "member title" that seems to be randomly attached when signing up. Your title is Space Invader. ;)

 

I used the Classic99 emulator. Code copied and pasted. Camtasia Studio for screen capture/recording and producing animation in the GIF format.

 

It reminds me of my early days in college writing code using a DECWriter printing terminal.

Isn't that also machine from the seventies ? ;)

Link to comment
Share on other sites

Those are our ranks based upon number of posts. The ranking pips under our names used to have definitions, but those stopped working about the time the custom message indicators disappeared from next to threads in the list.

Link to comment
Share on other sites

 

I'd add...

 

05 CALL CLEAR

1011 X=X+1

1012 IF X=23 THEN 1040 ELSE 1020

1040 END

 

As for doing it any better... beats me!

 

Slightly shorter (doesn't need the X=X+1):

1000 FOR I=1 TO LEN(A$)
1010 CALL HCHAR(Y,X+I-1,ASC(SEG$(A$,I,1)))
1020 NEXT I
1030 RETURN

Call like this:

10 A$="Hello world!"
20 Y=10
30 X=10
40 GOSUB 1000
50 END
Edited by Willsy
Link to comment
Share on other sites

Crap that won't work. Deleted. Hopefully nobody saw my mistake. Stupid BASE 1.

 

 

 

 

Slightly shorter (doesn't need the X=X+1):

1000 FOR I=1 TO LEN(A$)
1010 CALL HCHAR(Y,X+I-1,ASC(SEG$(A$,I,1)))
1020 NEXT I
1030 RETURN

Call like this:

10 A$="Hello world!"
20 Y=10
30 X=10
40 GOSUB 1000
50 END
Edited by unhuman
  • Like 1
Link to comment
Share on other sites

 

Six and two threes... You'd need to add 1 to x in the SEG$ statement :grin:

 

It is true -- somewhere there is a calculation which happens every iteration. I have to pull up one of my later programs. I think I finally settled on just requiring X to be base-0 before GOSUBing. But in any case, some variation of the tried-and-true method for TI BASIC. Until I got my MiniMemory and TI so graciously supplied a routine for that.

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...