Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:12 01 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 : PicoMite - response of an esc control sequence?

Author Message
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 471
Posted: 10:54pm 13 Nov 2021
Copy link to clipboard 
Print this post

how can i evaluate the response of an esc control sequence? this is output again directly at the terminal ...

Cursor Position Report
Invoked by ESC [ 6 n
Response is ESC [ Pl ; Pc R *
* Pl = line number; Pc = column number


> ? chr$(27)+"[6n";

> [24;1R

It is logical that this does not work:
> x=print chr$(27)+"[6n";
Error : Expression syntax
>
or that:
> line input chr$(27)+"[6n", test$
[9;1R
> print test$

But how then?
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 11:05pm 13 Nov 2021
Copy link to clipboard 
Print this post


test$ = chr$(27)+"[6n"
print test$

test$ = chr$(27)+"[6n"
line input test$,answer$
print answer$


I think is what you are trying to do.
I am not sure if your terminal appends the CRLF and if not, you cannot use line input

Jim
VK7JH
MMedit
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 11:57pm 13 Nov 2021
Copy link to clipboard 
Print this post

this probably demonstrates what you're after:

Const ESC=Chr$(27)
Print ESC "[2J";

Do
 Print ESC "[" Str$(1+(Rnd*20),0,0) ";" Str$(1+(Rnd*75),0,0) "f";
 Print "#" Chr$(8);

 A$=""
 I%=Timer+100
 Print ESC "[6n";

 Do
   A$=A$+Inkey$
 Loop Until (Right$(A$,1)="R") Or Timer>I%
 A$=Mid$(A$,3,Len(A$)-3)

 Print ESC "[23;1f" A$ Space$(8);
 Print ESC "[" A$ "f";
 Pause 2000
Loop



cheers,
rob   :-)
Edited 2021-11-14 12:14 by robert.rozee
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 08:12am 14 Nov 2021
Copy link to clipboard 
Print this post

you may find this usefule
http://www.fruitoftheshed.com/MMBasic.Simple-screen-Control-for-ANSI-based-Consoles-VT100-etc.ashx

and this which provides a more controllable "input" using the above
http://www.fruitoftheshed.com/MMBasic.String-editing-on-screen-for-VT-compatible-Terminals.ashx
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 08:12am 14 Nov 2021
Copy link to clipboard 
Print this post

<deleted duplicate>
Edited 2021-11-14 18:13 by CaptainBoing
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 471
Posted: 07:09pm 14 Nov 2021
Copy link to clipboard 
Print this post

thanks to all, I will try out the suggestions and examples and report back ...
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 471
Posted: 10:30pm 15 Nov 2021
Copy link to clipboard 
Print this post

There seems to be a difference between testing line input at the prompt and in the programme! Unfortunately, only the CRLF is really missing :-( in the programme version.

  TassyJim said  
I think is what you are trying to do.
I am not sure if your terminal appends the CRLF and if not, you cannot use line input.

Jim


It is a pity that it is not provided from the basic system. With the Inkey$ query with the Do Loop, keystrokes (especially the ESC key) can mess up a clean query :-( Here the system would have to ask the query and prevent any other input and react immediately to the ESC response, only then should the normal Inkey$ be used again.
So far I am not satisfied with any solution and will probably calculate the cursor position after a clear screen for all outputs and then always have the cursor position available. Or am I missing something in the examples, thanks for that.
But beautiful is different, isn't it?
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 11:36pm 15 Nov 2021
Copy link to clipboard 
Print this post

The device doesn't know how fast the characters are arriving and how long a line will be so you cannot rely on line input.

Serial comms is always going to require work on the programmers behalf.
How you do it depends on your overall program flow.

I am sorry that I can't provide you with a 'simple' solution.

Jim
VK7JH
MMedit
 
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