WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Boxes Functions
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Scrolling Status Screen Box

Keywords: boxesup  scrolling progress box

Question:

I would like to be able to put up a window and simply add text to it as I process in the background. For example, I delete a file and add a new line to the bottom of the existing text, as the text increases it simply scrolls down the screen and the old stuff scrolls off the top. Kind of like just writing msgs in a dos window, the new one goes at the end and when the screen is full it just scrolls up one.

Answer:

From your message, I gather that the following example will do what you wanted. You could also get fancier with this and make one of the lines 'static' that gives info such as "28% complete".

;setup variables
line1=""
line2=""
line3=""
line4=""
line5=""

BoxOpen("Scrolling Example","")

for x=1 to 10
	gosub scroll
	if x != 10
		line5="This is line %x%"
	else
		line5="DONE!"
	endif
	gosub update_disp
delay(1)
next x

message("DONE!","Example complete.")
exit()

:update_disp
line=StrCat(line1,"%@CRLF%",line2,"%@CRLF%",line3,"%@CRLF%",line4,"%@CRLF%",line5,"%@CRLF%")
BoxText(line)
return

:scroll
line1=line2
line2=line3
line3=line4
line4=line5
return

You can also do it with ths simple UDF.

Users Sample UDF:


;Scrolling text messages to show process progress
;==============================================================================
;Raymond Chevalier, November 2001
;==============================================================================
#DefineFunction scroll(scroll_txt, newline)
   if scroll_txt == "" then scroll_txt = newline
                       else scroll_txt = strcat(scroll_txt, @tab, newline)
   while itemcount(scroll_txt, @tab) > 9
      scroll_txt = itemremove(1, scroll_txt, @tab)
   endwhile
   BoxText(Strreplace(scroll_txt, @tab, @crlf))
   RETURN scroll_txt
#EndFunction
;========================================================
boxopen("Console", "")
scroll_txt = scroll("", "Beginning")

;some code here

scroll_txt = scroll(scroll_txt, "Line 2...")

;some code here

scroll_txt = scroll(scroll_txt, "Line 3...")

;Etc....

Or with a "real" console window:
hker = DllLoad("KERNEL32.DLL")
DLLCall(hker, long:"AllocConsole")
hStdOutput = DLLCall(hker, long:"GetStdHandle", long:-11)
linebuff = binaryalloc(256)
mret = BinaryAlloc(4)

for i = 1 to 200
line = strcat("Hello there ", i, @CRLF)
binarypokestr(linebuff, 0, line)
DLLCall(hker, long:"WriteConsoleA", long:hStdOutput, lpbinary:linebuff, long:strlen(line), lpbinary:mret, lpnull)
next

Message("", "done")
DLLCall(hker, long:"FreeConsole")
dllfree(hker)
binaryfree(linebuff)
binaryfree(mret)

Article ID:   W12769
Filename:   Scrolling Status Screen Box.txt
File Created: 2002:06:17:11:34:40
Last Updated: 2002:06:17:11:34:40