Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:44 02 Aug 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 : OPTION DISPLAY VALUES

     Page 2 of 2    
Author Message
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 07:17pm 07 Mar 2023
Copy link to clipboard 
Print this post

I started with the framework by shed user "flip" (who I think has not posted in a long time) here: MMBasic Multi-window Framework
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 07:34pm 07 Mar 2023
Copy link to clipboard 
Print this post

  Mark said  thwill:  Thanks for the tip. The code does work. I send an escape sequence to position the cursor to row 999 and column 999. I then send an ESC [6n to get the cursor position (thanks Captain), it then prints "[48;160R" on the screen matches my terminal set up.

The question now is how do I read that "[48;160R" into my program and not have it display on the screen?


I've never done it in MMBasic, only C, but my guess is that if it is possible then you do it using the INPUT$() function to read from file #0.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mark
Regular Member

Joined: 26/11/2022
Location: United States
Posts: 85
Posted: 09:01pm 07 Mar 2023
Copy link to clipboard 
Print this post

Print Chr$(27) "[999;999H" Chr$(27) "[6n"
Dim rows% = 0
Dim cols% = 0
Dim ic$
Dim v%
Dim rc% = 0
Do
 ic$ = Inkey$
Loop Until Len(ic$) > 0

Do
 ic$ = Inkey$
 If Len(ic$) = 0 Then
   Exit
 EndIf
 If ic$ = ";" Then
   rc% = 1
 Else
   v% = Asc(ic$) - 48
   If v% < 10 Then
     If rc% Then
       cols% = cols% * 10 + v%
     Else
       rows% = rows% * 10 + v%
     EndIf
   EndIf
 EndIf
Loop


Here's a snippet that I found works to get the terminal rows and columns.

Mark
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7938
Posted: 09:42pm 07 Mar 2023
Copy link to clipboard 
Print this post

It would be interesting to know if that will work generally. It wouldn't surprise me if some terminals didn't work with 999,999.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 09:45pm 07 Mar 2023
Copy link to clipboard 
Print this post

It doesn't look very robust timing-wise!

I'd want to delay a bit to give a chance for the whole response string to come in.

John
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 09:49pm 07 Mar 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  It would be interesting to know if that will work generally. It wouldn't surprise me if some terminals didn't work with 999,999.


tried it here with '170, and puTTY with VT100 emulation - following code:


Dim Integer rows,cols
Dim a$,l$
Print Chr$(27)"[999;999H"Chr$(27)"[6n"
'response looks something like ESC[28;1R   - rows;cols and no CRLF

Do While a$<>"R"' grab the response up to the "R"
a$=Inkey$
If a$<>"" Then l$=l$+a$
Loop

If Left$(l$,2)=Chr$(27)+"[" Then
rows=Val(mid$(l$,3))
cols=Val(Mid$(l$,Instr(l$,";")+1))
Print rows,cols
End if


works just fine (nice work Mark, good find Thwill) but then it has to if the VT100 emulation is good.
Edited 2023-03-08 08:12 by CaptainBoing
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:07pm 07 Mar 2023
Copy link to clipboard 
Print this post

My version
There seems to be a large number of chr$(0) sent before the data is returned. This is with TeraTerm (and MMCC) under Windows 11.
How many depends on the response time.
You also have to be prepared for very slow responses now that some end-users are playing with TCPIP.
 '
 PRINT "we are here"
 PRINT CHR$(27)+"[6n";
 DIM locate$ = ""
 DIM n
 DO
   k$ = INKEY$
   INC n
   'print asc(k$);" ";
   IF k$<>CHR$(0) AND k$<>CHR$(27) AND k$ <>"" THEN locate$ = locate$ + k$
 LOOP UNTIL k$ = "R" OR LEN(locate$) > 10 OR n > 1000000
 
 IF LEFT$(locate$,1) = "[" THEN
   col = VAL(MID$(locate$,2))
   row = VAL(FIELD$(locate$,2,";"))
 ENDIF
 PRINT "Terminal says "+locate$, row,col, n




Jim
VK7JH
MMedit
 
     Page 2 of 2    
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