Command RESTORE SCREEN Foundation

Redisplays previously saved screen contents.

Syntax
RESTORE SCREEN [FROM <cScreen>]
Parameters
<cScreen>
<cScreen> is a character string containing the characters which make up the screen, along with their color attributes.
Description

The command RESTORE SCREEN redisplays a complete screen previously saved using the command SAVE SCREEN. Both commands exist only for compatibility reasons. The function RestScreen() should be used instead of RESTORE SCREEN. Instead of SAVE SCREEN, the function SaveScreen() should be used.

The option FROM specifies a memory variable containing the character string representing the screen contents. If FROM is not specified, the command RESTORE SCREEN restores the screen from the internal screen buffer previously saved with SAVE SCREEN.

Examples
RESTORE SCREEN
// In the example, the user defined function MessageBox() 
// is programmed which emulates the function Alert(), 
// allowing colors to be specified. It shows a typical 
// use of SAVE SCREEN and RESTORE SCREEN. The screen is 
// saved at the beginning of the function and restored again 
// before leaving the function. 

PROCEDURE Main 

   USE Customer SHARED NEW 

   DO WHILE .T. 
      APPEND BLANK 
      IF Neterr() 
         IF MessageBox( "File is locked", ; 
                       {" Retry "," Cancel "}, ; 
                        "N/BG,W+/B"  ) == 2 
            EXIT 
         ENDIF 
      ELSE 
         MessageBox( "record was added" ) 
         EXIT 
      ENDIF 
   ENDDO 

   USE 
RETURN 

FUNCTION MessageBox( cText, aMenu, cColor ) 
   LOCAL nTop, nLeft, nBottom, nRight, ; 
         n, nCount, cScreen, cOldColor 

   SAVE SCREEN TO cScreen            // save screen 

   cOldColor:= SetColor( cColor )    // save color 
   nCount   := MlCount( cText, 40 )  // number of text rows 

   nTop     := Int( (MaxRow()-nCount-4) / 2 ) 
   nLeft    := 15                    // box coordinates 
   nBottom  := nTop + nCount + 4 
   nRight   := 65 

   IF Empty( aMenu ) 
      aMenu := {" Ok "}              // default option 
   ENDIF 
                                     // output box 
   @ nTop, nLeft CLEAR TO nBottom, nRight 
   @ nTop, nLeft TO nBottom, nRight DOUBLE 

   FOR n:=1 TO nCount                // output text rows 
      @ nTop+n, nLeft+1 SAY ;        // centered 
           PadC( Trim(MemoLine(cText,40,n)), 49 ) 
   NEXT 

   n := 0                            // determine total length 
   AEval( aMenu, {|c| n+=Len(c)} )   // of menu items 

   nCount:= Len( aMenu )             // number of menu items 
                                     // determine column for 
                                     // centered output 
   nLeft := nLeft + Int((nRight-nLeft-n) /2 ) 
   SetPos( nBottom-2, nLeft )        // position cursor 
   FOR n:=1 TO nCount                // display menu items 
      @ Row(),Col() PROMPT ( aMenu[n] ) 
   NEXT 

   MENU TO n                         // activate menu 

   SetColor( cOldColor )             // restore color 

   RESTORE SCREEN FROM cScreen       // restore screen 

RETURN n                             // return selection 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.