Page 1 of 1 1
Topic Options
#157321 - 2006-02-16 11:43 AM How format output to console screen?
flashcash5 Offline
Lurker

Registered: 2006-01-24
Posts: 4
Hi All, i have a nice grid and box defined as follows:
Color b+/n
Box (0,0,24,79,"grid")
Color g+/n
Box (0,18,100,60,"full")
Color w+/n

And all my text outputs to the console in a nice pattern in the middle when i use this style of formatting:
At (1,20) "Good Morning,"

BUT, when i get to my GPO updating and wsus - the automatic text output that comes out to the console is just standard. (Going from the far left of the screen)

Is there any way of setting it up so that any text or block of text that is about to be outputted is to stay in the middle of the console screen?

Many thanks in advance

Top
#157322 - 2006-02-16 01:14 PM Re: How format output to console screen?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Not easily.

You have two options:
1) Use something like KiXforms and display the output in a GUI form.
2) Use a console window library to display the output

Here is a console window library that I use, with an example of how to use it:

Code:
; vim600:ts=3 sw=3 ai filetype=kix

$=SetOption("Explicit","ON")
$=SetOption("HideCursor","OFF")

CLS

; Pane demo script.
;
; This demo shows two scrolling panes, displaying the contents of the Windows and System 32 directories.
;

Dim $paneWin,$paneSys
Dim $sWinFile, $sSysFile
Dim $iWinPass, $iSysPass

$iWinPass=1
$iSysPass=1

Box(3,9,12,60,"double")
Box(13,9,22,60,"double")
$paneWin=PaneCreate(4,10,8,50)
$paneSys=PaneCreate(14,10,8,50)

At(3,12) "Files present in "+%SYSTEMROOT%
At(13,12) "Files present in "+%SYSTEMROOT%+"\System32"

$sWinFile=Dir(%SYSTEMROOT%,0)
$sSysFile=Dir(%SYSTEMROOT%+"\System32",1)
While Not KBHit()

$paneWin=PaneWrite($paneWin,@CRLF+@TIME+" "+$iWinPass+" "+$sWinFile)
$PaneSys=PaneScrollDown($paneSys)
$paneSys=PaneAt($paneSys,0,0,@TIME+" "+$iSysPass+" "+$sSysFile)
PaneUpdate($paneWin,"w+/n")
PaneUpdate($paneSys,"g+/n")

$sWinFile=Dir("",0)
If @ERROR $iWinPass=$iWinPass+1 $sWinFile=Dir(%SYSTEMROOT%,0) EndIf
$sSysFile=Dir("",1)
If @ERROR $iSysPass=$iSysPass+1 $sSysFile=Dir(%SYSTEMROOT%+"\System32",1) EndIf
Sleep(0.2)
Loop

Get $

Exit 0

; Cut here 8<----------------------------------------------------------------------------------->8
; Begin Pane Functions


Function PaneCreate($iTop, $iLeft, $iHeight, $iWidth)

If Not IsDeclared($_Pane_Top)
Global $_Pane_Top ; Pane position offset from top of console
Global $_Pane_Left ; Pane position offset from left of console
Global $_Pane_Height ; Pane height
Global $_Pane_Width ; Pane width
Global $_Pane_Cursor_X ; Cursor vertical (Row)
Global $_Pane_Cursor_Y ; Cursor horizontal (Column)
Global $_Pane_Blank ; Enough spaces to blank a line
Global $_Pane_Change_X_Low ; First row with a change on it.
Global $_Pane_Change_X_High ; Last row with a change on it.
Global $_Pane_Content ; Actual pane content

$_Pane_Top=0
$_Pane_Left=1
$_Pane_Height=2
$_Pane_Width=3
$_Pane_Cursor_X=4
$_Pane_Cursor_Y=5
$_Pane_Blank=6
$_Pane_Change_X_Low=7
$_Pane_Change_X_High=8
$_Pane_Content=9
EndIf

Dim $P

ReDim $P[$_Pane_Content+1]

$P[$_Pane_Top]=CInt($iTop)
$P[$_Pane_Left]=CInt($iLeft)
$P[$_Pane_Height]=CInt($iHeight)
$P[$_Pane_Width]=CInt($iWidth)
$P[$_Pane_Cursor_X]=0
$P[$_Pane_Cursor_Y]=0
$P[$_Pane_Change_X_Low]=0
$P[$_Pane_Change_X_High]=$iHeight-1
$P[$_Pane_Content]=""

; Create the blank line field
While Len($P[$_Pane_Blank])<$iWidth $P[$_Pane_Blank]=Left($P[$_Pane_Blank]+" ",$P[$_Pane_Width]) Loop
; Blank the pane
While $iHeight $P[$_Pane_Content]=$P[$_Pane_Content]+$P[$_Pane_Blank] $iHeight=$iHeight-1 Loop

$PaneCreate=$P
EndFunction

Function PaneAt($P, $iRow, $iColumn, Optional $sText)
$P[$_Pane_Cursor_X]=CInt($iRow)
$P[$_Pane_Cursor_Y]=CInt($iColumn)
If $sText<>"" $P=PaneWrite($P,$sText) EndIf
$PaneAt=$P
EndFunction

Function PaneWrite($P,$sText)
Dim $X,$Y,$C,$s,$POS

$X=$P[$_Pane_Cursor_X]
$Y=$P[$_Pane_Cursor_Y]
$C=$P[$_Pane_Content]

While $sText<>""
$s=Left($sText,1)
Select
Case $s=Chr(10)
$X=$X+1
If $X=$P[$_Pane_Height]
$X=$X-1
$P[$_Pane_Content]=$C
$P=PaneScrollUp($P)
$C=$P[$_Pane_Content]
EndIf
Case $s=Chr(13)
$Y=0
Case 1
$Y=$Y+1
If $Y=$P[$_Pane_Width]
$Y=0
$sText="X"+Chr(10)+$sText
Else
$POS=$X*$P[$_Pane_Width]+$Y+1
$C=CStr(SubStr($C,1,$POS-1))+$S+SubStr($C,$POS+1)
EndIf
EndSelect
$sText=SubStr($sText,2)
Loop
$P[$_Pane_Cursor_X]=$X
$P[$_Pane_Cursor_Y]=$Y
$P[$_Pane_Content]=$C

$PaneWrite=$P
EndFunction

Function PaneScrollUp($P)
$P[$_Pane_Content]=SubStr($P[$_Pane_Content],$P[$_Pane_Width]+1)+$P[$_Pane_Blank]
$PaneScrollUp=$P
EndFunction

Function PaneScrollDown($P)
$P[$_Pane_Content]=Left($P[$_Pane_Blank]+$P[$_Pane_Content],$P[$_Pane_Width]*$P[$_Pane_Height])
$PaneScrollDown=$P
EndFunction

Function PaneUpdate($P, Optional $sColor)
Dim $sCursorState,$i

$sCursorState=SetOption("HideCursor","ON")
For $i=0 To $P[$_Pane_Height]
If $sColor Color $sColor EndIf
At($P[$_Pane_Top]+$i, $P[$_Pane_Left])
SubStr($P[$_Pane_Content],1+$P[$_Pane_Width]*$i,$P[$_Pane_Width])
Next

At($P[$_Pane_Top]+$P[$_Pane_Cursor_X], $P[$_Pane_Left]+$P[$_Pane_Cursor_y])

$sCursorState=SetOption("HideCursor",$sCursorState)

EndFunction


Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 271 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.05 seconds in which 0.024 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