Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- RLIB 3.0a Reference - <b>an example</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
An Example

   The following is an example of a help system which utilizes the RHELP
   API functions contained in the RLIB function library.  This help
   system reads help text from a designated help file and displays the
   text centered on the screen.

   *=====================================================================
   * Procedure:  Help                                                    
   * Purpose:    Generic help module.                                    
   * Syntax:     DO help WITH (helpkey), (helpfile)                      
   * Parameters: helpkey  - The text of the "Help keyword" to lookup     
   *             helpfile - Name of the RHELP compiled help (.HLP) file. 
   *=====================================================================
   PROCEDURE Help                                                        
   PARAMETERS sv_helpkey, sv_hlpfile                                     
                                                                         
   PRIVATE inrow, incol, incolor, inscreen, incursor                     
   PRIVATE help_text, help_width, help_lines, HelpColor                  
   PRIVATE win_width, win_lines, win_top, win_left, win_bottom, win_right
                                                                         
   IF TYPE("sv_helpkey") + TYPE("sv_hlpfile") != "CC"                    
      RETURN                                                             
   ENDIF                                                                 
   IF .NOT. FILE(sv_hlpfile)                                             
      BLIP()                                                             
      BOXASK( "Help file " + sv_hlpfile + " does not exist",;            
              "Help is not available", "Press any key to return", 30 )   
      SETCURSOR(incursor)                                                
      RETURN                                                             
   ENDIF                                                                 
   helpColor  = "B/W"                        && set your color here      
   incursor   = SETCURSOR(.F.)               && save and turn off cursor 
   inrow      = ROW()                                                    
   incol      = COL()                                                    
   help_lines = RH_LINES( sv_hlpfile, sv_helpkey )                       
   help_width = RH_WIDTH( sv_hlpfile, sv_helpkey )                       
   help_text  = RH_TEXT(  sv_hlpfile, sv_helpkey )                       
                                                                         
   IF help_lines = 0 .OR. help_width = 0 .OR. EMPTY(help_text)           
      BOXASK(HelpColor,"No help available","Press any key to return",30) 
   ELSE                                                                  
      win_width  = MIN( help_width, 76 )                                 
      win_lines  = MIN( help_lines, 20 )                                 
      win_top    = 11 - ROUND(win_lines / 2, 0)     && middle of screen  
      win_bottom = win_top + win_lines + 1          && calc bottom row   
      win_left   =  2 + INT( (76 - win_width) / 2 )                      
      win_right  = 79 - win_left                                         
      incolor    = SETCOLOR(HelpColor)                                   
      inscreen   = SAVESCREEN(win_top,win_left-2,win_bottom,win_right+2) 
      @ win_top, win_left-2, win_bottom, win_right+2 BOX "+-+|+-+| "     
      @ win_top,   37 SAY " Help "                                       
      @ win_bottom,26 SAY " Press ESCAPE to exit help "                  
      MEMOEDIT(help_text,win_top+1,win_left,win_bottom-1,win_right,;     
               .F., "", help_width)                                      
      RESTSCREEN(win_top,win_left-2,win_bottom,win_right+2,inscreen)     
      SETCOLOR(incolor)                                                  
      @ inrow,incol SAY ""                                               
   ENDIF                                                                 
   SETCURSOR(incursor)                                                   
   RETURN                                                                


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson