Page 1 of 1 1
Topic Options
#124699 - 2004-08-10 07:40 PM cursor control/movement
cb6040 Offline
Fresh Scripter

Registered: 2003-06-03
Posts: 14
Loc: FL
Good afternoon,

I'm tweaking my logon script and I wanted to make the network drive attachment give me more feedback, so I wanted to use At() to move the cursor, to say, put a checkmark next to a drive once it has been successfully connected.

Are there variables that store the current COLUMNS/ROWS positions so that I can use At()? I want to 'start drawing at the beginning of the current line'.. wish I could At(,1) to specify to go to position 1 on the current line but it doesn't seem like I can. I could figure this stuff out if i knew the current rows/columns, though..

anyone with experience w/ At() care to speak up? thanks

Top
#124700 - 2004-08-10 09:52 PM Re: cursor control/movement
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Generally, checkmark (or checkbox) is done with a space or spacebar.

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#124701 - 2004-08-10 10:07 PM Re: cursor control/movement
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The whole point of using AT() is to maintain control over where on the screen you are outputting. That said, it is up to you to ALSO maintain control of ALL other output. If you know what is on the screen where, you would know where AT() to put the checkmark.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124702 - 2004-08-10 10:51 PM Re: cursor control/movement
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Here is an idea:

Code:
 
$label=" This is a test to see what will happen"
? $label
sleep 3
for $i=1 to len($label)
chr(8)
next
"X"



Basically, all this is doing is displaying the LABEL, waiting a few seconds, then pressing the backspace key the same number of times as the length of LABEL, and then adding the "X" (checkmark).

HTH

Top
#124703 - 2004-08-10 11:01 PM Re: cursor control/movement
cb6040 Offline
Fresh Scripter

Registered: 2003-06-03
Posts: 14
Loc: FL
Ok... so, to bring the cursor to the beginning of a line, I would need to keep track of the # of lines drawn prior, and then use that to get At to move to the right location? does that sound right? I agree with what you're saying, but I'm not trying to draw every x and y, just manipulate what's on that line. I see no easy way of doing that..

I'm printing things like this:
Code:
 	
? " [x] $DriveLetter ($UNCPath) [cleaning]"
USE $DriveLetter /delete
USE $DriveLetter $UNCPath
IF ((@error <> 0) and (@error <> 85) and (@error <> 1202))
? " [!] $DriveLetter ($UNCPath) [failed]"
ELSE ? " [û] $DriveLetter ($UNCPath) [done]"
ENDIF



I'd like to delete the previously written text, or bring the cursor there to overwrite it. I could do this with At easily if it had @COLUMN @ROW macros..

Top
#124704 - 2004-08-10 11:05 PM Re: cursor control/movement
cb6040 Offline
Fresh Scripter

Registered: 2003-06-03
Posts: 14
Loc: FL
sigh.. it would be a lot of hacked code to tracking every cursor movement on the entire display just because I want to manipulate the current line. The logon script scrolls like any other, it's only on those specific lines that I need that ability.

If Kixtart doesn't do that, maybe we should ask whomever writes it to implement something- because At() from what I gather is useless unless you want your whole app to work through it.. and track movement by hand.. which is quite ridiculous for this case and i'm sure a host of others.


Edited by cb6040 (2004-08-10 11:16 PM)

Top
#124705 - 2004-08-10 11:16 PM Re: cursor control/movement
cb6040 Offline
Fresh Scripter

Registered: 2003-06-03
Posts: 14
Loc: FL
cool, i'll try that
Top
#124706 - 2004-08-11 10:16 AM Re: cursor control/movement
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Simple anwer for your initial question is that to move the cursor to the start of the line you just need to send a carriage return character Chr(13).

Here is a simple example:
Code:
For $i = 5 To 0 Step -1
Chr(13) $i
Sleep 0.5
Next
Chr(13) "Done" ?



Of course you still don't know where you are on the console (other than that you are in column 0).

Another option is to use an external program which will tell you where you are on the screen.

I have a small executable (7k) which will report console size, buffer size, and the current cursor position.

It will also provide a screen-dump of the visible console in a KiXtart friendly format.

Top
#124707 - 2004-08-11 09:14 PM Re: cursor control/movement
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
As I understood it, he wanted to return to the beginning of the line he is currently on.
Top
#124708 - 2004-08-11 09:31 PM Re: cursor control/movement
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
As I understood it, it could be anywhere on the console or even scrolled off the screen since he does not want to keep track of what is where.

I mean, if he placed the text on the screen with AT(), and was careful not to let it overflow and scroll, he would know where to put the checkmark AT().
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124709 - 2004-08-11 11:31 PM Re: cursor control/movement
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
I won't argue that if you are using AT, then keeping up with where you are is the best method. But in two different post he eludes to wanting to get back to the beginning of the current line:

Quote:


I want to 'start drawing at the beginning of the current line'




Quote:


just because I want to manipulate the current line





I think what has confused this is he wants to use AT, and the answer is, you can't use AT unless you keep up with the output, or as Richard suggested, use another program to keep up with the cursor.

This seems clear as mud. Maybe CB6040 can point us in the right direction.

Top
#124710 - 2004-08-12 10:01 AM Re: cursor control/movement
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

I mean, if he placed the text on the screen with AT(), and was careful not to let it overflow and scroll, he would know where to put the checkmark AT().




My guess is that the screen output will comprise both text from the script, and output from commands that are run.

To know where he is he needs to capture the output (including errors) from the commands, work out the console size, displays the output using KiXtart and calculate the cursor position (taking into account screen scrolling).

He may well be handing control to a program which he cannot capture output from, so cannot determine where on the screen the cursor will be left.

It's pretty heavy stuff and guaranteed to fail in some cases.

FWIW I've always thought it would be useful to allow the AT() parameters to be optional, and/or have macros which return the cursor position. It's such a simple process I'm surprised it hasn't made it in despite repeated requests. Perhaps it just wasn't popular enough.

Top
#124711 - 2004-08-12 10:37 AM Re: cursor control/movement
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

As I understood it, he wanted to return to the beginning of the line he is currently on.




Yes, this is what a carriage return does. Try the example script.

To move to the next line requires a newline Chr(10) as well.

Most console drivers unfortunately automatically convert Chr(10) -> Chr(10)+Chr(13). Happily, a carriage return on it's own is left unaltered and can be used to return you to the start of the line.

Here is a slightly more amusing example, an input field with a countdown timer. Note, AT() isn't used at all.
Code:
Break ON

$=SetOption("ASCII","ON")

$sTyped=""
$sCommand="halt"
$dCounter=10.0
$dInterval=0.1
$sColour="rrrryyyyggggggg"

$sText=Chr(13)+'Type "'+$sCommand+'" before the countdown expires! : '
While $sCommand AND $dCounter > 0
If KBHit()
Get $k
If $k=Left($sCommand,1)
$sTyped=$sTyped+$k
$sCommand=SubStr($sCommand,2)
EndIf
EndIf
Color w/n $sText
Color n/g+ $sTyped
Color r+/n $sCommand
Color w/n " [ Time left: "
$sNextColor=SubStr($sColour,1+CInt($dCounter),1)+"+/n"
Color $sNextColor CInt($dCounter)
Color w/n "] "
Sleep $dInterval
$dCounter=$dCounter-$dInterval
Loop

If $sCommand
Color r+/n
Chr(13)+" KABOOM! You were too late! " ?
Else
Chr(13)+" Phew, you made it with "+Cint($dCounter)+" seconds left! " ?
EndIf


Top
#124712 - 2004-08-12 04:02 PM Re: cursor control/movement
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Richard,

CHR(13)... Point taken...noted... and will be added to my bag of tricks. That is a better way.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 765 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.113 seconds in which 0.074 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org