home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / MT_MTX12.ZIP / GRAF-D3.ZIP / GRAF-D3.PPS < prev   
Encoding:
Text File  |  1993-07-01  |  9.4 KB  |  239 lines

  1. ;*****************************************************************************
  2. ;*                                                                           *
  3. ;*                           ANSI DETECTION V2.1                             *
  4. ;*                                                                           *
  5. ;*                        written by: Steve Catmull                          *
  6. ;*                 additional coding: David Terry                            *
  7. ;*                                                                           *
  8. ;*                            started: 04-26-93                              *
  9. ;*                                                                           *
  10. ;*****************************************************************************
  11.  
  12.  
  13. BOOLEAN hasansi     ; Result of ANSI - detection test (true or false)
  14. BOOLEAN hasrip      ; Result of ANSI - detection test (RIP & ANSI)
  15. STRING  graphdef    ; Stores response to the "ask" prompt below
  16. STRING  ask         ; Constant that contains "want graphics" minus default resp.
  17. INTEGER numticks    ; Used to store number of clock ticks that I have waited.
  18. INTEGER maxticks    ; Stores the maximum number of ticks to wait for response.
  19. STRING  temp        ; Stores the token of what user inputed.
  20. STRING  default_yes ; Used to store setting from PCBOARD.DAT for the default
  21. STRING  rest_ANSI   ; Store rest of input buffer if any after ANSI CPR.
  22. STRING  temp_dir    ; Temporary/work directory as defined in PCBSetup
  23. STRING  bkspace     ; Sequence of characters for destructive backspace  dwt
  24. STRING  esc         ; Constant used instead of chr(27)
  25. STRING  cr_lf       ; Constant used instead of chr(13)+chr(10)
  26.  
  27. BOOLEAN recorded    ; temporary.  Delete -- not needed.  SLC 04/28/93
  28. BOOLEAN compatible  ; Used to determine is sysop wants to use compatible mode.
  29. STRING  nonews      ; For parsing out what user enters
  30. STRING  nowelc      ; For parsing out what user enters
  31. STRING  ansi        ; For parsing out what user enters
  32. STRING  rip         ; For parsing out what user enters
  33. STRING  noansi      ; For parsing out what user enters
  34. STRING  autoansr    ; Used to skip graphics question if graphics detected
  35.  
  36. temp    = ""                             ; Initialized to non null for WHILE
  37. bkspace = chr(8)+chr(32)+chr(8)          ; destructive backspace  dwt
  38. maxticks = 50   ; (50/18.2 seconds)
  39. esc = chr(27)
  40. cr_lf = chr(13)+chr(10)
  41.  
  42. ; Analyze Command line passed
  43.  
  44. temp=gettoken()
  45. while (temp != "") DO
  46.    if (mid(upper(temp),2,1) = "W") then
  47.       maxticks = mid(temp,instr(temp,":")+1,2)
  48.       if (maxticks < 1 | maxticks = "")  maxticks=50
  49.       if (mid(upper(temp),11,1) = "C") then          ; Test For /COMPATIBLE Arg
  50.          compatible = true                           ; Set compatible if true
  51.       else if (mid(upper(temp),11,1) = "A") then     ; OR Test For /AUTO Arg
  52.          autoansr = true                             ; Set autoansr if true
  53.       endif
  54.    else if (mid(upper(temp),2,1) = "C") then
  55.       compatible = true
  56.    else if (mid(upper(temp),2,1) = "A") then
  57.       autoansr = true
  58.    endif
  59.    temp=gettoken()
  60. endwhile
  61. temp="" ; Return temp how we found it.
  62.  
  63.  
  64. ; /* Notifying the user that ANSI detection is being processed.  This keeps
  65. ;    them entertainment while the "ansitime" pause is being executed.  */
  66.  
  67. PRINTLN "[ Auto-Detecting Emulation ]"   ; Amusing the caller.
  68.  
  69. ; /* If you user is connected locally then default autoamtically to ANSI
  70. ;    capable.  Otherwise, send out the escape sequence to get the current
  71. ;    cursor position.  Immediately follow that with a bunch of backspace
  72. ;    space backspace sequences in case they do not have the ability to
  73. ;    interpret ANSI.  Otherwise, it may be left on the screen.  Finally,
  74. ;    wait for the and ESC followed by a left bracket to be returned.  This
  75. ;    is the only constant part of the ANSI detection that can be tested.
  76. ;    If that sequence is returned within ANSITIME seconds, then the caller
  77. ;    is considered to be ANSI capable and the HASANSI variable shows it.
  78. ;
  79. ;    NOTE:  Evidently some terminal programs are quite lazy in returning
  80. ;           the response to the ANSI detection test.  This PPE does not
  81. ;           attempt to make any accomodations for those programs.  Instead,
  82. ;           it waits "ANSITIME" seconds and then continues with the best that
  83. ;           has been determined by that time.                            */
  84.  
  85.  
  86. if (onlocal()) then
  87.    hasansi=TRUE
  88. else
  89.    print esc+"[!"
  90.    print bkspace+bkspace+bkspace
  91.    print esc+" F"
  92.    print bkspace+bkspace+bkspace
  93.    print esc+"[6n"
  94.    print bkspace+bkspace+bkspace+bkspace
  95.  
  96.    temp = chr(mgetbyte())
  97.  
  98.    while (temp = "" & numticks <= maxticks) do
  99.       temp = chr(mgetbyte())
  100.       if (temp != "") then
  101.          recorded = true
  102.       else
  103.          delay 2
  104.          numticks = numticks + 2
  105.       endif
  106.    endwhile
  107.  
  108.    if (temp = "R") then
  109.       while (temp != "" | len(rest_ansi) < 9) do
  110.          rest_ansi=rest_ansi+temp
  111.          temp=chr(mgetbyte())
  112.          if (temp = "") then
  113.            delay 2
  114.            temp = chr(mgetbyte())
  115.          endif
  116.       endwhile
  117.       if (left(rest_ansi,3)="RIP") then
  118.          hasrip=TRUE
  119.          hasansi=TRUE
  120.       endif
  121.    else if (temp = esc) then
  122.       while (temp != "") do
  123.          rest_ansi=rest_ansi+temp
  124.          temp=chr(mgetbyte())
  125.          if (temp="") then
  126.             delay 2
  127.             temp = chr(mgetbyte())
  128.          endif
  129.       endwhile
  130.       tokenize rest_ansi
  131.       temp = gettoken()
  132.       temp = mid(temp,2,len(temp-1))
  133.       if ((temp >= 0 | temp <= 80) & (right(GETTOKEN(),1)="R")) then
  134.          hasansi=TRUE
  135.       else
  136.          hasansi=FALSE
  137.       endif
  138.    endif
  139. endif
  140.  
  141.  
  142. ; /* Assign ASK variable to prompt used for ANSI.  The default if enter is
  143. ;    pressed is ommitted so that it may be built according to their ANSI
  144. ;    capabilities.                                                       */
  145.  
  146. ask = "Do you want graphics (Enter)="
  147.  
  148. ; /* Read line #257 in PCBOARD.DAT to find out what the default for the
  149. ;    "Do you want graphics" prompt is.  Store the result in DEFAULT_YES.
  150.  
  151. default_yes = READLINE(PCBDAT(),257)
  152.  
  153. ; /* If the default to the "Do you want graphics prompt is "Yes", then
  154. ;    inform the sysop via a message that the system is configured improperly. */
  155.  
  156. IF (default_yes) THEN
  157.    temp_dir = READLINE(PCBDAT(),179)
  158.    SPRINTLN
  159.    SPRINTLN "┌───────────────────────────────────────────────────────────────────┐"
  160.    SPRINTLN "│ Your system is improperly configured for use with the GRAF-D.PPE  │"
  161.    SPRINTLN "│ file.  You have configured it to default to Yes for the 'Do you   │"
  162.    SPRINTLN "│ want graphics' prompt.  You need to change that setting to 'N' in │"
  163.    SPRINTLN "│ PCBSetup | Configuration Options | Configuration Switches.        │"
  164.    SPRINTLN "└───────────────────────────────────────────────────────────────────┘"
  165.    SPRINTLN
  166.    PRINT "Do you want graphics (Enter)=no"
  167.    END
  168. ENDIF
  169.  
  170. ; /* If the user is capable of ANSI, then default for the "want graphics"
  171. ;    prompt will be Yes, otherwise, the default is set to "N".  The point
  172. ;    in asking the question is to enable the user to still choose if they
  173. ;    wish to see color or not, but if they do not know how to answer the
  174. ;    question, then the default will give them color if they are capable
  175. ;    of handling it.
  176.  
  177. IF (hasansi) THEN
  178.  
  179.    IF (hasrip) THEN
  180.       if (compatible) then
  181.          println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m     RIPscrip detected and it will be the default    "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
  182.       else
  183.          ask=ask+"RIPscrip"
  184.       endif
  185.    ELSE
  186.       if (compatible) then
  187.          println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m     ANSI detected and it will be the default    "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
  188.       else
  189.          ask=ask+"yes"
  190.       endif
  191.    ENDIF
  192.  
  193.    if (compatible) ask = ask + "default"
  194.  
  195. ELSE
  196.    if (compatible) then
  197.       println cr_lf + "[* No graphics capabilities detected.  This will be the default *]"
  198.       ask = ask + "default"
  199.    else
  200.       ask=ask+"no"
  201.   endif
  202. ENDIF
  203.  
  204. if ((autoansr & ! hasansi)  | !autoansr) then         ; Skip if user has ANSI and AUTO stuff is enabled
  205.  
  206.    INPUTSTR ask,graphdef,07,6,"QSR",FIELDLEN+LFBEFORE+LFAFTER+STACKED+UPCASE+YESNO
  207.    IF (graphdef="" & !hasansi) graphdef=NOCHAR()
  208.  
  209.    ; /* Now that the "want graphics" prompt has been faked so that the default
  210.    ;    value could be controlled, it is time to stuff the users response to
  211.    ;    the fake prompt to the real prompt.  This inludes the "Q and NS"
  212.    ;    parameters.                                                           */
  213.  
  214.    if (instr(graphdef,"NS")) then
  215.       nonews="NS"
  216.       graphdef=left(graphdef,instr(graphdef,"NS")-1)+right(graphdef,len(graphdef)-(instr(graphdef,"NS")+1))
  217.    endif
  218.  
  219.    if (instr(graphdef,yeschar())) ansi = yeschar()+";"
  220.    if (instr(graphdef,nochar())) noansi = nochar()+";"
  221.    if (instr(graphdef,"Q")) nowelc = ""
  222.    if (instr(graphdef,"R")) rip = "R;"
  223.  
  224. endif
  225.  
  226.    if (hasrip & noansi = "" & ansi = "") then
  227.       rip = "R;"
  228.    else if (hasansi & noansi = "" & rip = "") then
  229.       ansi = yeschar()+";"
  230.    endif
  231.  
  232.    if (rip != "" & ansi != "") rip = ""
  233.    if (rip != "" & noansi != "") rip = ""
  234.    if (ansi != "" & noansi != "") ansi = ""
  235.  
  236. KBDSTUFF rip+ansi+noansi+nowelc+nonews
  237.  
  238. END                                    ; end of script
  239.