Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:45 07 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : VT100 subroutine cheater for micromite

Author Message
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 05:28pm 29 Jun 2014
Copy link to clipboard 
Print this post

As I'm converting a few basic program to run on the Micromite, I've noticed a few commands that are missing, but very easily generated using the subroutine function.

Here's a quick cheater of handy subroutines for VT100 functions:

CLS
[code]
SUB CLS
PRINT CHR$(27)+"[f" : PRINT CHR$(27)+"[2J"
END SUB
[/code]

LOCATE X,Y
[code]
SUB LOCATE X,Y
PRINT CHR$(27)+"["+STR$(X)+";"+STR$(Y)+"f";
END SUB
[/code]

COLOR f,b
[code]
SUB COLOR f,b
PRINT CHR$(27)+"[0;"+STR$(f)+";"+STR$(b)+";1m";
END SUB
[/code]

If you guys have others, please post them.

Jeff

My Propeller/Micromite mini-computer project.
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 05:42pm 29 Jun 2014
Copy link to clipboard 
Print this post

Jeff,
You need to add a semi-colon (;) at the end of the PRINT line in the CLS sub.

I've always maintained that some of the built-in commands could easily be done in MMBasic code.

Regards, Bob Devries
Dalby, QLD, Australia

Bob Devries
Dalby, QLD, Australia
 
cosmic frog
Guru

Joined: 09/02/2012
Location: United Kingdom
Posts: 302
Posted: 01:18am 30 Jun 2014
Copy link to clipboard 
Print this post

I was thinking about the very same idea last night!

Dave.
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 06:30am 30 Jun 2014
Copy link to clipboard 
Print this post

It's a shame I can't "edit" my original post and add that.

Maybe a moderator would be kind enough to plug that in so that the OP is correct.

Thanks for the catch!

Jeff
Edited by Oldbitcollector 2014-07-01
My Propeller/Micromite mini-computer project.
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 11:09am 30 Jun 2014
Copy link to clipboard 
Print this post

According to the information at the bottom of the screen (page), You *can* edit your own posts. Not sure how though.

Regards, Bob Devries
Dalby, QLD, Australia

Bob Devries
Dalby, QLD, Australia
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4036
Posted: 11:36am 30 Jun 2014
Copy link to clipboard 
Print this post

You can, but I think only until anyone posts a later message.

I often correct my typos :)

John
 
jeffj
Regular Member

Joined: 04/02/2012
Location: Australia
Posts: 84
Posted: 07:22pm 11 Sep 2016
Copy link to clipboard 
Print this post

I have recently found this old post for printing on Vt100 and UMite
I cannot get it to work and have some funny things happening
any ideas anyone
Jeff



This is my test programme


autosave
main:

x=100
y=200
gosub locate x,y
end

LOCATE X,Y :
PRINT CHR$(27)+"["+STR$(X)+";"+STR$(Y)+"f";
END SUB
'================================================
> list
main:

x=100
y=200
GoSub locate x,y
End

Sub LOCATE X,Y
Print Chr$(27)+"["+Str$(X)+";"+Str$(Y)+"f";
End Sub

'==============================================
This print out when I try to run

> run
[5] GoSub locate x,y
Error: Cannot find label
'===============================================
Try again with ":" after sub name LOCATE X,Y
> autosave
main:

x=100
y=200
gosub locate x,y
end

LOCATE X,Y :
PRINT CHR$(27)+"["+STR$(X)+";"+STR$(Y)+"f";
END SUB
'================================================
This is confirmation that ":" has been entered on LOCATE X,Y

> list
autosave
main:

x=100
y=200
gosub locate x,y
end

LOCATE X,Y :
PRINT CHR$(27)+"["+STR$(X)+";"+STR$(Y)+"f";
END SUB

'=================================================
Error when I try to run

> run
[5] GoSub locate x,y
Error: Cannot find label
'================================================
Note ":" has disappeared from LOCATE X,Y
list
main:

x=100
y=200
GoSub locate x,y
End

LOCATE X,Y
Print Chr$(27)+"["+Str$(X)+";"+Str$(Y)+"f";
End Sub
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 08:06pm 11 Sep 2016
Copy link to clipboard 
Print this post

You are mixing the 'old' GOSUB method with the newer SUB xxx method.
Try this version:
main:

x=10
y=20
locate x,y
PRINT "Here we are"
END

SUB LOCATE X,Y
PRINT CHR$(27)+"["+STR$(X)+";"+STR$(Y)+"f";
END SUB


You also need to keep the X and Y values within the terminal range - usually 80 by 24 or 36
We are talking characters not pixels.

JimEdited by TassyJim 2016-09-13
VK7JH
MMedit
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9589
Posted: 09:46pm 11 Sep 2016
Copy link to clipboard 
Print this post

I really like the VT100 for simple B/W output from a Micromite or other.

The routines I have been using recently:


'------------------------------------------------------------------
Sub MENU (T$)
WIPE
Print #2,Chr$(27)+"[6m"; 'Select Jumbo font
Print #2,Chr$(27)+"[7m"; 'Select Inverse Video
Print #2,Chr$(27)+"[4m"; 'Select Underline mode
Print #2,T$ 'Print menu title
STANDARD 'Select standard text mode(turn all text attributes off)
Print #2,NL$ 'Blank line for space
LARGE 'Select Large font
End Sub
'-------------------------------------------------------------------
Sub WIPE
Print #2,Chr$(27)+"c"; 'Reset terminal
Print #2,Chr$(27)+"[2J"; 'Clear entire screen
Print #2,Chr$(27)+"[H"; 'Cursor to top-left
End Sub
'-------------------------------------------------------------------
Sub BORDER
Print #2,Chr$(27)+"[Z2;0;0;285;212Z"; 'Draw border box
End Sub
'-------------------------------------------------------------------
Sub LARGE
Print #2,Chr$(27)+"[3m"; 'Large font
End Sub
'-------------------------------------------------------------------
Sub STANDARD
Print #2,Chr$(27)+"[0m"; 'Standard font
End Sub
'-------------------------------------------------------------------





Smoke makes things work. When the smoke gets out, it stops!
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 10:08pm 11 Sep 2016
Copy link to clipboard 
Print this post

I thought that all of the above would not work as it does not follow my own practice of defining subroutines and having the parameters between brackets.

I checked the manual and in the section about defined subroutines it uses different styles. Old style with a label, new style with and without brackets.
I wonder why that is. It sure must be a nightmare for the firmware to parse all these styles.
Why not have only one style and stick to it.
Especially users new to MMBasic get confused after reading that section in the manual. You want them to start with the best practice.
like:
[code]
SUB LOCATE (X, Y)
PRINT CHR$(27)+"["+STR$(X)+";"+STR$(Y)+"f";
END SUB
[/code]

I think it is more readable.
The label version should in my opinion be removed as it is much more prone to runtime errors.


Microblocks. Build with logic.
 
jeffj
Regular Member

Joined: 04/02/2012
Location: Australia
Posts: 84
Posted: 07:54pm 12 Sep 2016
Copy link to clipboard 
Print this post

Thanks for yr posts Ok I get now.
Both Microblocks and Tassie Jims' worked ok.
Grogsters is very impressive of what can be done. I am a bit confused as it looks like it is set up for a serial link.
I am very much on my L Plates re this printing minefield
Any other print sub commands would be gratefully received.
regards Jeff
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9589
Posted: 02:28pm 13 Sep 2016
Copy link to clipboard 
Print this post

Oh yeah, sorry everyone - that code I posted is for a MM controlling a VT100 chip.
I just posted it for the text size commands etc, but I expect you can extract that easy enough from that example code. Probably should have said that above - sorry for any confusion there....
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025