home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / PRO98SRC.ZIP / PROFORM.BAS < prev    next >
BASIC Source File  |  1994-01-01  |  4KB  |  113 lines

  1. ' PROFORM: Prozol screen format and database map generator
  2. $ERROR ALL ON
  3. $DIM ARRAY
  4. $COMPILE EXE
  5. $OPTION GOSUB ON  ' This is a MUST
  6. DECLARE SUB GetStrLoc() 'we have to declare this because we need it
  7. DIM FORM(25) AS STRING * 80
  8. DIM GEN$(255)
  9. %FALSE = 0
  10. %TRUE  = NOT %FALSE
  11. ' These are the parameters that you need to pass to PBWRITE
  12.  
  13.        BoxTOP% = 2     ' top of the editor window
  14.       BoxLEFT% = 1     ' left of window
  15.     BoxBOTTOM% = 22    ' bottom of window
  16.      BoxRIGHT% = 81    ' right of window
  17.     TextAttribute% = &H1E  ' Color of the text   (bg=0, fg=7)
  18.   BorderAttribute% = &H4F  ' Color of the border (bg=7, fg=0)
  19.        Margin% = 0     ' Right margin for word wrap
  20.  
  21.     CursorRow% = 0     ' default to 0, these contain the current -
  22.     CursorCol% = 0     '  cursor and position within the document -
  23.        DocPointer% = 0     '  allowing you to re-enter the subroutine -
  24.     DocOffset% = 0     '  with the document state preserved.
  25.                '  Call PBWRITE again later with these
  26.                '  variables preserved, and you will appear
  27.                '  inside the document exactly as you left it.
  28.  
  29.  FileName$ = "NONAME.GEN"  '  This is the default filename for LOAD/SAVE
  30.  ExitCode% = 0             '  returns the scancode of the exit key
  31.  
  32. ' save the screen and cursor position
  33.  
  34. TEMP$ = SAVESCREEN$:X%=CSRLIN:Y%=POS(0)
  35. FOR i=1 to 23:ED$=ED$+SPACE$(80)+CHR$(13,10):NEXT i
  36.  
  37. ' Just call the PBWRITE subroutine.  It is recursive and entirely self
  38. ' contained.  You may call it as many times as you want with different
  39. ' parameters to edit different documents.
  40. CLS
  41. LOCATE 1,1:COLOR 15,4:PRINT SPACE$(80);
  42. LOCATE 23,1:PRINT SPACE$(80);
  43. COLOR 15,1:PRINT SPACE$(80);
  44. LOCATE 24,1:PRINT "F2-Save F3-Load  F10-Generate";
  45. PBWRITE     ED$,_               ' string to contain the whole document
  46.         BoxTOP%,_           ' dimensions of the edit window
  47.         BoxLEFT%,_          '
  48.         BoxBOTTOM%,_        '
  49.         BoxRIGHT%,_         '
  50.         CursorRow%,_        ' default to 0, these contain the current -
  51.         CursorCol%,_        ' cursor and position within the document -
  52.         DocPointer%,_       ' allowing you to re-enter the subroutine -
  53.         DocOffset%,_        ' with the document state preserved.
  54.         FileName$,_         ' This is just the default name for SAVE/LOAD
  55.         TextAttribute%,_    ' The color of the text
  56.         BorderAttribute%,_  ' The color of the border
  57.         Margin%,_           ' The Right Margin
  58.         ExitCode%           ' key used to exit editor
  59.  
  60. ' Restore the screen and cursor position
  61.  
  62. RESTORESCREEN TEMP$:LOCATE X%, Y%, 1  ' make sure cursor is visible
  63.  
  64. IF ExitCode%<>68 THEN END
  65. IF RIGHT$(ED$,2)<>CHR$(13,10) THEN ED$=ED$+CHR$(13,10)
  66. i=0
  67. IF INSTR(FILENAME$,".")=0 THEN FILENAME$=FILENAME$+"."
  68. MASTER$=LEFT$(FILENAME$,INSTR(FILENAME$,".")-1)
  69. MAPFILE$="MAP "+MASTER$+" TO ????"
  70.  
  71. DO UNTIL ED$=""
  72. INCR i
  73. TEMP$=LEFT$(ED$,INSTR(ED$,CHR$(13))-1)
  74. ED$=MID$(ED$,LEN(TEMP$)+3)
  75. FORM(i)=TEMP$+SPACE$(80-LEN(TEMP$))
  76.     DO
  77.         a=instr(form(i),":")
  78.         if a=0 then exit loop
  79.         b=instr(form(i),">")
  80.         if b=0 then exit loop ''''''''''''' THIS IS ACTUALLY AN ERROR
  81.         c=a
  82.                 do
  83.                   decr c
  84.                 loop until mid$(form(i),c,1)=" " or c=1
  85.                 if mid$(form(i),c,1)=" " then incr c
  86.                 fld$=ucase$(mid$(form(i),c,a-c))
  87.                 flen=b-a:mapflen=mapflen+flen
  88.                 row=i
  89.                 col=c
  90.                 incr gen
  91. gen$(gen)="FIELD"+STR$(gen)+CHR$(32,34)+MASTER$+"."+Fld$+CHR$(34,44,34,67,34,44)+str$(flen)+","+STR$(row)+","+STR$(col)
  92. mapfile$=mapfile$+"_"+CHR$(13,10)+SPACE$(8)+STR$(flen)+" AS "+Fld$
  93.     mid$(form(i),1)=space$(b) ' cover up to ">"
  94.     LOOP
  95.  
  96. LOOP
  97. replace "????" with str$(mapflen) in mapfile$
  98. PRINT "WRITING FIELD DEFINITION FILE - "+MASTER$+".FLD"
  99. OPEN MASTER$+".FLD" FOR OUTPUT AS #1
  100.  
  101. FOR i=1 TO GEN
  102.     PRINT #1, GEN$(i)
  103. NEXT i
  104. CLOSE #1
  105. PRINT "WRITING MAP DEFINITION FILE - "+MASTER$+".MAP"
  106. OPEN MASTER$+".MAP" FOR OUTPUT AS #1
  107. PRINT #1, MAPFILE$
  108. CLOSE
  109. END
  110.  
  111. ' =========================================================================
  112. $INCLUDE "PBWRITE.BAS"
  113.