home *** CD-ROM | disk | FTP | other *** search
/ Fujiology Archive / fujiology_archive_v1_0.iso / !MAGS / !BONUS / COVERDSK / STFORMAT / STF40.ZIP / STF40A.MSA / AUTOZEST / ENTRY.LST < prev    next >
File List  |  2004-11-04  |  4KB  |  79 lines

  1. PROCEDURE text_entry_box(max_length%,upper_y%)
  2.   ' Here's a quick and simple text entry box for use with the ZeST interface.
  3.   ' Simply pass the maximum length (max_length%) of the text string (string$)
  4.   ' and the upper_y% coordinate for the top of the text entry box.
  5.   ' The display will be automatically centered for you.
  6.   ' --------------------------------------------------------------------------
  7.   ' max_length% for text input cannot exceed 74 characters or be less than 0
  8.   IF max_length%>74 OR max_length%<0 THEN
  9.     max_length%=74
  10.   ENDIF
  11.   ' upper_y% for top of text entry box cannot be more than 350 or less then 0
  12.   IF upper_y%<0 OR upper_y%>350 THEN
  13.     upper_y%=350
  14.   ENDIF
  15.   ' --------------------------------------------------------------------------
  16.   ' calculate the box width in relation to the maximum text string length
  17.   l_side%=INT(639-(max_length%*8))/2
  18.   r_side%=639-l_side%
  19.   ' --------------------------------------------------------------------------
  20.   ' store the screen section where the text entry box will be drawn
  21.   GET l_side%-27,upper_y%-2,r_side%+27,upper_y%+52,putback$
  22.   ' --------------------------------------------------------------------------
  23.   ' draw a platform and place a text box inside based on the calculations
  24.   GOSUB zest_button(l_side%-25,upper_y%,r_side%+25,upper_y%+50)
  25.   GOSUB zest_text_box(l_side%-15,upper_y%+10,r_side%+15,upper_y%+40)
  26.   ' --------------------------------------------------------------------------
  27.   ' calculate the correct postion of the string within the text window
  28.   x_pos%=l_side%
  29.   y_pos%=upper_y%+31
  30.   ' --------------------------------------------------------------------------
  31.   ' make sure the input string starts out empty and display the cursor
  32.   string$=""
  33.   TEXT x_pos%,y_pos%,CHR$(95)
  34.   ' --------------------------------------------------------------------------
  35.   DO
  36.     ' continuously test for a keypress (don't forget upper and lower case!)
  37.     KEYTEST key
  38.     IF key<>0 THEN
  39.       SELECT key
  40.       CASE 1835021,7471117,275906573,270270477
  41.         ' RETURN or ENTER key
  42.         ' exit loop if the return key is pressed and string$ contains text
  43.         EXIT IF TRIM$(string$)<>""
  44.       CASE 6356992,274792448
  45.         ' UNDO key
  46.         string$=""
  47.         ' clear string$ and exit loop when undo key is pressed
  48.         EXIT IF TRIM$(string$)=""
  49.       CASE 4915200,273350656
  50.         ' LEFT KEY
  51.       CASE 5046272,273481728
  52.         ' RIGHT KEY
  53.       CASE 917512,269352968
  54.         ' BACKSPACE key
  55.         ' remove only the last character of string$
  56.         IF LEN(string$)>0 THEN
  57.           string$=LEFT$(string$,(LEN(string$)-1))
  58.           TEXT x_pos%,y_pos%,string$+CHR$(95)+SPACE$(max_length%-LEN(string$))
  59.         ENDIF
  60.       CASE 65563,268501019
  61.         ' ESC key
  62.         ' clear string$ when ESC is pressed
  63.         string$=""
  64.         TEXT x_pos%,y_pos%,string$+CHR$(95)+SPACE$(max_length%-LEN(string$))
  65.       DEFAULT
  66.         ' if string length will not be exceeded then add the character pressed
  67.         IF LEN(string$)<max_length% THEN
  68.           string$=string$+CHR$(key)
  69.           ' also calculate how many empty spaces to place after string$
  70.           TEXT x_pos%,y_pos%,string$+CHR$(95)+SPACE$(max_length%-LEN(string$))
  71.         ENDIF
  72.       ENDSELECT
  73.     ENDIF
  74.   LOOP
  75.   ' --------------------------------------------------------------------------
  76.   ' put back the original screen section after using the text entry box
  77.   PUT l_side%-27,upper_y%-2,putback$
  78. RETURN
  79.