![]() |
Forum Index : Microcontroller and PC projects : VT100 subroutine cheater for micromite
Author | Message | ||||
Oldbitcollector![]() Senior Member ![]() Joined: 16/05/2014 Location: United StatesPosts: 172 |
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: AustraliaPosts: 266 |
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 KingdomPosts: 302 |
I was thinking about the very same idea last night! Dave. |
||||
Oldbitcollector![]() Senior Member ![]() Joined: 16/05/2014 Location: United StatesPosts: 172 |
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 My Propeller/Micromite mini-computer project. |
||||
BobDevries![]() Senior Member ![]() Joined: 08/06/2011 Location: AustraliaPosts: 266 |
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 KingdomPosts: 4036 |
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: AustraliaPosts: 84 |
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: AustraliaPosts: 6269 |
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. Jim VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9589 |
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: ThailandPosts: 2209 |
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: AustraliaPosts: 84 |
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 ZealandPosts: 9589 |
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! |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |