home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a075 / 1.img / TOOLKIT1.EXE / SST56.PRG < prev    next >
Encoding:
Text File  |  1989-10-05  |  5.8 KB  |  196 lines

  1. ********************
  2.              
  3. FUNCTION Makemenu
  4.  
  5.    PARAMETERS _choices, _menrow, _mencol, _menstart, _mentype, _topdown, ;
  6.               _spacing, _botrow, _tqfill, _messages, _helpprog
  7.  
  8.    PRIVATE _thismen, _lowerlvl, _isarray, _uptohere, _themen, _qaz
  9.    PRIVATE _brow, _bcol, _showit, _messit
  10.  
  11.    IF TYPE("_menstart") = "C"
  12.       _thismen = &_menstart.   && Using Pop-Help, the name of the menu 
  13.       _lowerlvl = .T.          && variable should be passed and not the value:
  14.    ELSE                        && here is where it should check it out.
  15.       _thismen = _menstart
  16.       _lowerlvl = .F.
  17.    ENDIF
  18.  
  19.    DO CASE
  20.    CASE PCOUNT() < 4
  21.       RETURN(0)
  22.    CASE PCOUNT() = 4
  23.       _mentype = 1
  24.       _topdown = .T.
  25.       _spacing = 1
  26.       _botrow = 24
  27.       _tqfill = 0
  28.       _messages = ""
  29.    CASE PCOUNT() = 5
  30.       _topdown = .T.
  31.       _spacing = 1
  32.       _botrow = 24
  33.       _tqfill = 0
  34.       _messages = ""
  35.    CASE PCOUNT() = 6
  36.       _spacing = 1
  37.       _botrow = 24
  38.       _tqfill = 0
  39.       _messages = ""
  40.    CASE PCOUNT() = 7
  41.       _botrow = 24
  42.       _tqfill = 0
  43.       _messages = ""
  44.    CASE PCOUNT() = 8
  45.       _tqfill = 0
  46.       _messages = ""
  47.    CASE PCOUNT() = 9
  48.       _messages = ""
  49.    ENDCASE
  50.  
  51.    IF TYPE("scr_level") = "U"
  52.       PUBLIC allscreens[20], scr_level, allcolor[20], allwindows[20]
  53.       AFILL(allscreens, "")
  54.       AFILL(allcolor, "")
  55.       AFILL(allwindows, "")
  56.       scr_level = 1
  57.    ELSE
  58.       _botrow = Wrow(Wdepth())
  59.    ENDIF
  60.  
  61.    _helpprog = IF( TYPE("_helpprog") = "U", PROCNAME(), _helpprog )
  62.  
  63.    IF TYPE("_choices") = "A"
  64.       _isarray = .T.
  65.    ELSE
  66.       _isarray = .F.
  67.       DECLARE _themen[Occurence("/",_choices)+1]
  68.       _uptohere = Occurence("/",_choices) + 1         
  69.       FOR _qaz = 1 TO LEN(_themen)
  70.          _themen[_qaz] = Parsing(@_choices)
  71.       NEXT
  72.    ENDIF
  73.   
  74.    IF EMPTY(_tqfill)
  75.       _tqfill = IF( _isarray, Length_el(_choices), Length_el(_themen) )
  76.       IF _tqfill > 78
  77.          _tqfill = 78  && Just in case someone wants to be funny and have a menu with a longer window!
  78.       ENDIF
  79.    ENDIF
  80.  
  81.    STORE _menrow TO _brow 
  82.    STORE _mencol TO _bcol
  83.  
  84.    FOR _qaz = 1 TO IF( _isarray, LEN(_choices), LEN(_themen) )
  85.  
  86.       IF _qaz > 32   && This tests to see if there are more than 32
  87.          EXIT        && elements for a MENU TO command.
  88.       ENDIF
  89.  
  90.       IF _isarray
  91.          IF TYPE("_choices[_qaz]") != "U"
  92.             _showit = _choices[_qaz]
  93.          ELSE
  94.             _showit = ""
  95.          ENDIF
  96.       ELSE
  97.          _showit = _themen[_qaz]
  98.       ENDIF
  99.  
  100.       IF TYPE("_messages") = "A"
  101.          _messit = _messages[_qaz]
  102.       ELSE
  103.          IF !EMPTY(_messages)
  104.             _messit = Parsing(@_messages)
  105.          ELSE
  106.             _messit = ""
  107.          ENDIF
  108.       ENDIF
  109.  
  110.       DO CASE   
  111.       CASE _mentype = 1          && Numbers In Front
  112.          _showit = SUBSTR(Fill_out(" " + CHR(IF(_qaz > 9, 55, 48) + _qaz) + ;
  113.                    "> " + _showit, _tqfill + 4), 1, _tqfill + 4)
  114.       CASE _mentype = 2          && <> separators
  115.          _showit = SUBSTR(_showit, 1, 1)
  116.       CASE _mentype = 3          && 1 space in front and in back
  117.          _showit = SUBSTR(Fill_out(" " + _showit, _tqfill + 2), 1, _tqfill + 2)
  118.       ENDCASE
  119.       IF _mentype = 2
  120.          @ _brow, _bcol SAY "< >" + ;
  121.            SUBSTR( IF(_isarray, _choices[_qaz], _themen[_qaz]), 2)
  122.       ENDIF
  123.       @ _brow, _bcol + IF(_mentype=2, 1, 0) PROMPT _showit MESSAGE _messit
  124.  
  125. *************************************
  126. * NOTE: This function has to be modified to test for the length
  127. * of a prompt and to see if it will and should wrap around on the screen,
  128. * then the function should automatically truncate it off.
  129. *************************************
  130.  
  131.       IF _qaz + 1 <= IF( _isarray, LEN(_choices), LEN(_themen) )
  132.          IF _topdown                      && top down type of menu
  133.             _brow = _brow + _spacing
  134.             IF _brow > _botrow
  135.                _brow = _menrow
  136.                _bcol = _bcol + _tqfill + 5
  137.             ENDIF
  138.          ELSE                             && right to left type of menu
  139.             DO CASE
  140.             CASE _mentype = 1
  141.                t_col = _bcol + LEN(_showit) + ;
  142.                        IF( _isarray, LEN(_choices[_qaz]), ;
  143.                        LEN(_themen[_qaz]) ) + 4
  144.  
  145.             CASE _mentype = 2
  146.                t_col = _bcol + LEN(_showit) + ;
  147.                        IF( _isarray, LEN(_choices[_qaz]), ;
  148.                        LEN(_themen[_qaz]) ) + 3 + ;
  149.                        IF( _isarray, LEN(_choices[_qaz]), ;
  150.                        LEN(_themen[_qaz]) )
  151.  
  152.             CASE _mentype = 3
  153.                t_col = _bcol + LEN(_showit) + ;
  154.                        IF( _isarray, LEN(_choices[_qaz]), ;
  155.                        LEN(_themen[_qaz]) ) + 2
  156.  
  157.             OTHERWISE
  158.                t_col = _bcol + LEN(_showit) + ;
  159.                        IF( _isarray, LEN(_choices[_qaz]), ;
  160.                        LEN(_themen[_qaz]) ) + 1
  161.  
  162.             ENDCASE
  163.             IF t_col > 80
  164.                _brow = _brow + 1
  165.                _bcol = _mencol
  166.             ELSE
  167.                IF _isarray
  168.                   _bcol = _bcol + IF(_mentype = 2, ;
  169.                           LEN(_choices[_qaz])+ 3, 0) + LEN(_showit) + 1
  170.                ELSE
  171.                   _bcol = _bcol + IF(_mentype = 2, ;
  172.                           LEN(_themen[_qaz])+ 3, 0) + LEN(_showit) + 1
  173.                ENDIF
  174.             ENDIF
  175.          ENDIF
  176.       ENDIF
  177.       _showit = ""
  178.    NEXT
  179.    scrcursor = .F.
  180.    SET CURSOR OFF
  181.    IF _lowerlvl
  182.       MENU TO &_menstart
  183.       _thismen = &_menstart.
  184.    ELSE
  185.       MENU TO _thismen
  186.    ENDIF
  187.    SET CURSOR ON
  188.    IF TYPE("scrmess") <> "U"
  189.       IF TYPE("_messages") = "A"
  190.          @ scrmess,00 
  191.       ENDIF
  192.    ENDIF
  193.    RETURN(_thismen)
  194.  
  195. * End of File
  196.