Hide / Show a Console?
Posted: Sat Oct 01, 2016 2:44 pm
Hi all,
I hope it is ok if I pick your brains again?
I am writing a small utility program which I am using to "dump" the contents of a multi-dimensional array to screen (a bit like print_r() in PHP). The simplest way to do this is for me in this situation is to use a console screen.
My question: is it possible to hide the console screen until I am ready to display text on it? The screen shot below shows the program when it starts running.
1. On line 2 of the source code I all REQUEST HB_GT_WIN_DEFAULT - when the program starts, the console screen (I added a red box around it in the image) appears before the main window (the one with a "Show Array" button). * I WANT TO HIDE THIS CONSOLE *
2. When the "Show Array" button is clicked, it calls the function on line 54 (ShowArray). This is when I want to *SHOW THE CONSOLE *
Maybe I have missed something simple? I tried SET CONSOLE OFF and SET CONSOLE ON but that did not work.
Thanks!
Zim
I hope it is ok if I pick your brains again?
I am writing a small utility program which I am using to "dump" the contents of a multi-dimensional array to screen (a bit like print_r() in PHP). The simplest way to do this is for me in this situation is to use a console screen.
My question: is it possible to hide the console screen until I am ready to display text on it? The screen shot below shows the program when it starts running.
1. On line 2 of the source code I all REQUEST HB_GT_WIN_DEFAULT - when the program starts, the console screen (I added a red box around it in the image) appears before the main window (the one with a "Show Array" button). * I WANT TO HIDE THIS CONSOLE *
2. When the "Show Array" button is clicked, it calls the function on line 54 (ShowArray). This is when I want to *SHOW THE CONSOLE *
Maybe I have missed something simple? I tried SET CONSOLE OFF and SET CONSOLE ON but that did not work.
Thanks!
Zim
Code: Select all
#include "hmg.ch"
REQUEST HB_GT_WIN_DEFAULT
FUNCTION Main()
/*
Sample program for Chapter 11 - Advanced Data Types
This sample creates a multi-dimensional array which contains several different data types.
Users can add more elements and / or change values as the learn about arrays. When rthe click
on the "Show Array" button, the entire contents of the array, including all nested arrays, will
be displayed on a console screen showing the element number, data type and value in
that element.
*/
LOCAL nlblRow := 16
LOCAL nlblCol := 16
// Create a memory variable that will be an array
LOCAL aBigArray1 := { }
/*
Add the first two elements using the AADD array function. These are both arrays and each contains 5 elements
*/
AADD(aBigArray1, {.T., "Smith", Nil, "Married", "Customer"} )
AADD(aBigArray1, {".F.", "Jones", Nil, DATE(), "Employee"} )
/*
Add the next two elements using the AADD array function. The first one is an array that also contains another array
at element position 3. The second one is also an array that also contains another array but this time at element
position 4
*/
AADD(aBigArray1, { "Paul", "Brown", {"Mary", "Bob", "Billy"}, "Married", "Employee" } )
AADD(aBigArray1, { "Mike", "White", Nil, {16, 5, 22}, "Customer"} )
AADD(aBigArray1, "Customer" )
SET FONT TO "Arial", 10
SET DATE BRITISH
SET CONSOLE OFF
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 704 ;
HEIGHT 480 ;
TITLE "Array Test Three" ;
MAIN
DEFINE BUTTON btn_01
ROW nlblRow * 3
COL nlblCol
CAPTION "Show Array"
AUTOSIZE .T.
ONCLICK ShowArray(aBigArray1)
END BUTTON
END WINDOW
CENTER WINDOW Win_1
ACTIVATE WINDOW Win_1
Return Nil /* -- End of FUNCTION Main() -- */
FUNCTION ShowArray(aArray)
LOCAL nRow := 1
LOCAL nCol := 2
LOCAL cText := ""
SetMode(75, 100)
CLS
@ ++nRow, nCol SAY "Number of elements in this array: " + ALLTRIM(STR(LEN(aArray)))
++nRow
ShowElement(aArray, @nRow, nCol)
RETURN Nil /* -- End of FUNCTION ShowArray() -- */
FUNCTION ShowElement(aArray, nRow, nCol)
LOCAL i := 0
FOR i := 1 TO LEN(aArray)
IF VALTYPE(aArray[i]) == "U"
@ ++nRow, nCol SAY "-> Element " + ALLTRIM(STR(i)) + " - * NIL *"
ELSEIF VALTYPE(aArray[i]) == "B"
@ ++nRow, nCol SAY "-> Element " + ALLTRIM(STR(i)) + " - * CODE BLOCK *"
ELSEIF VALTYPE(aArray[i]) == "C"
@ ++nRow, nCol SAY "-> Element " + ALLTRIM(STR(i)) + " - 'CHARACTER' - value: " + aArray[i]
ELSEIF VALTYPE(aArray[i]) == "N"
@ ++nRow, nCol SAY "-> Element " + ALLTRIM(STR(i)) + " - 'NUMERIC' - value: " + STR(aArray[i])
ELSEIF VALTYPE(aArray[i]) == "L"
@ ++nRow, nCol SAY "-> Element " + ALLTRIM(STR(i)) + " - 'LOGICAL' - value: " + IIF(aArray[i], "True", "False")
ELSEIF VALTYPE(aArray[i]) == "D"
@ ++nRow, nCol SAY "-> Element " + ALLTRIM(STR(i)) + " - 'DATE' - value: " + DTOC(aArray[i])
ELSE
@ ++nRow, nCol SAY "-> Element " + ALLTRIM(STR(i)) + " - 'ARRAY' "
ShowElement(aArray[i], @nRow, nCol + 5)
ENDIF
NEXT i
Return Nil /* -- End of FUNCTION ShowElement() -- */
/* -- End of file -- */