home *** CD-ROM | disk | FTP | other *** search
- ********************
-
- FUNCTION Makemenu
-
- PARAMETERS _choices, _menrow, _mencol, _menstart, _mentype, _topdown, ;
- _spacing, _botrow, _tqfill, _messages, _helpprog
-
- PRIVATE _thismen, _lowerlvl, _isarray, _uptohere, _themen, _qaz
- PRIVATE _brow, _bcol, _showit, _messit
-
- IF TYPE("_menstart") = "C"
- _thismen = &_menstart. && Using Pop-Help, the name of the menu
- _lowerlvl = .T. && variable should be passed and not the value:
- ELSE && here is where it should check it out.
- _thismen = _menstart
- _lowerlvl = .F.
- ENDIF
-
- DO CASE
- CASE PCOUNT() < 4
- RETURN(0)
- CASE PCOUNT() = 4
- _mentype = 1
- _topdown = .T.
- _spacing = 1
- _botrow = 24
- _tqfill = 0
- _messages = ""
- CASE PCOUNT() = 5
- _topdown = .T.
- _spacing = 1
- _botrow = 24
- _tqfill = 0
- _messages = ""
- CASE PCOUNT() = 6
- _spacing = 1
- _botrow = 24
- _tqfill = 0
- _messages = ""
- CASE PCOUNT() = 7
- _botrow = 24
- _tqfill = 0
- _messages = ""
- CASE PCOUNT() = 8
- _tqfill = 0
- _messages = ""
- CASE PCOUNT() = 9
- _messages = ""
- ENDCASE
-
- IF TYPE("scr_level") = "U"
- PUBLIC allscreens[20], scr_level, allcolor[20], allwindows[20]
- AFILL(allscreens, "")
- AFILL(allcolor, "")
- AFILL(allwindows, "")
- scr_level = 1
- ELSE
- _botrow = Wrow(Wdepth())
- ENDIF
-
- _helpprog = IF( TYPE("_helpprog") = "U", PROCNAME(), _helpprog )
-
- IF TYPE("_choices") = "A"
- _isarray = .T.
- ELSE
- _isarray = .F.
- DECLARE _themen[Occurence("/",_choices)+1]
- _uptohere = Occurence("/",_choices) + 1
- FOR _qaz = 1 TO LEN(_themen)
- _themen[_qaz] = Parsing(@_choices)
- NEXT
- ENDIF
-
- IF EMPTY(_tqfill)
- _tqfill = IF( _isarray, Length_el(_choices), Length_el(_themen) )
- IF _tqfill > 78
- _tqfill = 78 && Just in case someone wants to be funny and have a menu with a longer window!
- ENDIF
- ENDIF
-
- STORE _menrow TO _brow
- STORE _mencol TO _bcol
-
- FOR _qaz = 1 TO IF( _isarray, LEN(_choices), LEN(_themen) )
-
- IF _qaz > 32 && This tests to see if there are more than 32
- EXIT && elements for a MENU TO command.
- ENDIF
-
- IF _isarray
- IF TYPE("_choices[_qaz]") != "U"
- _showit = _choices[_qaz]
- ELSE
- _showit = ""
- ENDIF
- ELSE
- _showit = _themen[_qaz]
- ENDIF
-
- IF TYPE("_messages") = "A"
- _messit = _messages[_qaz]
- ELSE
- IF !EMPTY(_messages)
- _messit = Parsing(@_messages)
- ELSE
- _messit = ""
- ENDIF
- ENDIF
-
- DO CASE
- CASE _mentype = 1 && Numbers In Front
- _showit = SUBSTR(Fill_out(" " + CHR(IF(_qaz > 9, 55, 48) + _qaz) + ;
- "> " + _showit, _tqfill + 4), 1, _tqfill + 4)
- CASE _mentype = 2 && <> separators
- _showit = SUBSTR(_showit, 1, 1)
- CASE _mentype = 3 && 1 space in front and in back
- _showit = SUBSTR(Fill_out(" " + _showit, _tqfill + 2), 1, _tqfill + 2)
- ENDCASE
- IF _mentype = 2
- @ _brow, _bcol SAY "< >" + ;
- SUBSTR( IF(_isarray, _choices[_qaz], _themen[_qaz]), 2)
- ENDIF
- @ _brow, _bcol + IF(_mentype=2, 1, 0) PROMPT _showit MESSAGE _messit
-
- *************************************
- * NOTE: This function has to be modified to test for the length
- * of a prompt and to see if it will and should wrap around on the screen,
- * then the function should automatically truncate it off.
- *************************************
-
- IF _qaz + 1 <= IF( _isarray, LEN(_choices), LEN(_themen) )
- IF _topdown && top down type of menu
- _brow = _brow + _spacing
- IF _brow > _botrow
- _brow = _menrow
- _bcol = _bcol + _tqfill + 5
- ENDIF
- ELSE && right to left type of menu
- DO CASE
- CASE _mentype = 1
- t_col = _bcol + LEN(_showit) + ;
- IF( _isarray, LEN(_choices[_qaz]), ;
- LEN(_themen[_qaz]) ) + 4
-
- CASE _mentype = 2
- t_col = _bcol + LEN(_showit) + ;
- IF( _isarray, LEN(_choices[_qaz]), ;
- LEN(_themen[_qaz]) ) + 3 + ;
- IF( _isarray, LEN(_choices[_qaz]), ;
- LEN(_themen[_qaz]) )
-
- CASE _mentype = 3
- t_col = _bcol + LEN(_showit) + ;
- IF( _isarray, LEN(_choices[_qaz]), ;
- LEN(_themen[_qaz]) ) + 2
-
- OTHERWISE
- t_col = _bcol + LEN(_showit) + ;
- IF( _isarray, LEN(_choices[_qaz]), ;
- LEN(_themen[_qaz]) ) + 1
-
- ENDCASE
- IF t_col > 80
- _brow = _brow + 1
- _bcol = _mencol
- ELSE
- IF _isarray
- _bcol = _bcol + IF(_mentype = 2, ;
- LEN(_choices[_qaz])+ 3, 0) + LEN(_showit) + 1
- ELSE
- _bcol = _bcol + IF(_mentype = 2, ;
- LEN(_themen[_qaz])+ 3, 0) + LEN(_showit) + 1
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- _showit = ""
- NEXT
- scrcursor = .F.
- SET CURSOR OFF
- IF _lowerlvl
- MENU TO &_menstart
- _thismen = &_menstart.
- ELSE
- MENU TO _thismen
- ENDIF
- SET CURSOR ON
- IF TYPE("scrmess") <> "U"
- IF TYPE("_messages") = "A"
- @ scrmess,00
- ENDIF
- ENDIF
- RETURN(_thismen)
-
- * End of File