![]() |
Forum Index : Microcontroller and PC projects : PicoMite - response of an esc control sequence?
Author | Message | ||||
homa![]() Guru ![]() Joined: 05/11/2021 Location: GermanyPosts: 471 |
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: AustraliaPosts: 6283 |
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 ZealandPosts: 2442 |
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 KingdomPosts: 2170 |
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 KingdomPosts: 2170 |
<deleted duplicate> Edited 2021-11-14 18:13 by CaptainBoing |
||||
homa![]() Guru ![]() Joined: 05/11/2021 Location: GermanyPosts: 471 |
thanks to all, I will try out the suggestions and examples and report back ... |
||||
homa![]() Guru ![]() Joined: 05/11/2021 Location: GermanyPosts: 471 |
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. 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: AustraliaPosts: 6283 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |