home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pcboard / grafd200.zip / GRAF-D.PPS < prev   
Text File  |  1993-05-07  |  9KB  |  229 lines

  1. ;*****************************************************************************
  2. ;*                                                                           *
  3. ;*                           ANSI DETECTION V2.0                             *
  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.  
  35. temp    = ""                             ; Initialized to non null for WHILE
  36. bkspace = chr(8)+chr(32)+chr(8)          ; destructive backspace  dwt
  37. maxticks = 50   ; (50/18.2 seconds)
  38. esc = chr(27)
  39. cr_lf = chr(13)+chr(10)
  40.  
  41. ; Analyze Command line passed
  42.  
  43. temp=gettoken()
  44. while (temp != "") DO
  45.    if (mid(upper(temp),2,1) = "W") then
  46.       maxticks = mid(temp,instr(temp,":")+1,2)
  47.       if (maxticks < 1 | maxticks = "")  maxticks=50
  48.    else if (mid(upper(temp),2,1) = "C") then
  49.       compatible = true
  50.    endif   
  51.    temp=gettoken()
  52. endwhile
  53. temp="" ; Return temp how we found it.
  54.  
  55.  
  56. ; /* Notifying the user that ANSI detection is being processed.  This keeps
  57. ;    them entertainment while the "ansitime" pause is being executed.  */
  58.  
  59. PRINTLN "Testing your system capability..."   ; Amusing the caller.
  60.  
  61. ; /* If you user is connected locally then default autoamtically to ANSI
  62. ;    capable.  Otherwise, send out the escape sequence to get the current
  63. ;    cursor position.  Immediately follow that with a bunch of backspace
  64. ;    space backspace sequences in case they do not have the ability to
  65. ;    interpret ANSI.  Otherwise, it may be left on the screen.  Finally,
  66. ;    wait for the and ESC followed by a left bracket to be returned.  This
  67. ;    is the only constant part of the ANSI detection that can be tested.
  68. ;    If that sequence is returned within ANSITIME seconds, then the caller
  69. ;    is considered to be ANSI capable and the HASANSI variable shows it.
  70. ;
  71. ;    NOTE:  Evidently some terminal programs are quite lazy in returning
  72. ;           the response to the ANSI detection test.  This PPE does not
  73. ;           attempt to make any accomodations for those programs.  Instead,
  74. ;           it waits "ANSITIME" seconds and then continues with the best that
  75. ;           has been determined by that time.                            */
  76.  
  77.  
  78. if (onlocal()) then
  79.    hasansi=TRUE
  80. else
  81.    print esc+"[!"
  82.    print bkspace+bkspace+bkspace
  83.    print esc+" F"
  84.    print bkspace+bkspace+bkspace
  85.    print esc+"[6n"
  86.    print bkspace+bkspace+bkspace+bkspace
  87.  
  88.    temp = chr(mgetbyte())
  89.  
  90.    while (temp = "" & numticks <= maxticks) do
  91.       temp = chr(mgetbyte())
  92.       if (temp != "") then
  93.          recorded = true
  94.       else
  95.          delay 2
  96.          numticks = numticks + 2
  97.       endif
  98.    endwhile
  99.  
  100.    if (temp = "R") then
  101.       while (temp != "" | len(rest_ansi) < 9) do
  102.          rest_ansi=rest_ansi+temp
  103.          temp=chr(mgetbyte())
  104.          if (temp = "") then
  105.            delay 2
  106.            temp = chr(mgetbyte())
  107.          endif
  108.       endwhile      
  109.       if (left(rest_ansi,3)="RIP") then
  110.          hasrip=TRUE
  111.          hasansi=TRUE
  112.       endif
  113.    else if (temp = esc) then
  114.       while (temp != "") do
  115.          rest_ansi=rest_ansi+temp
  116.          temp=chr(mgetbyte())
  117.          if (temp="") then
  118.             delay 2
  119.             temp = chr(mgetbyte())
  120.          endif
  121.       endwhile
  122.       tokenize rest_ansi
  123.       temp = gettoken()
  124.       temp = mid(temp,2,len(temp-1))
  125.       if ((temp >= 0 | temp <= 80) & (right(GETTOKEN(),1)="R")) then
  126.          hasansi=TRUE
  127.       else
  128.          hasansi=FALSE
  129.       endif
  130.    endif
  131. endif
  132.  
  133.  
  134. ; /* Assign ASK variable to prompt used for ANSI.  The default if enter is
  135. ;    pressed is ommitted so that it may be built according to their ANSI
  136. ;    capabilities.                                                       */
  137.  
  138. ask = "Do you want graphics (Enter)="
  139.  
  140. ; /* Read line #257 in PCBOARD.DAT to find out what the default for the
  141. ;    "Do you want graphics" prompt is.  Store the result in DEFAULT_YES.
  142.  
  143. default_yes = READLINE(PCBDAT(),257)
  144.  
  145. ; /* If the default to the "Do you want graphics prompt is "Yes", then
  146. ;    inform the sysop via a message that the system is configured improperly. */
  147.  
  148. IF (default_yes) THEN
  149.    temp_dir = READLINE(PCBDAT(),179)
  150.    FCREATE 1,temp_dir+"ANSI-D.$$$",O_RW,S_DW
  151.    FPUTLN 1,"The PPE shown in the subject, could not run properly because you"
  152.    FPUTLN 1,"have your system configured to Default to Yes for the 'Do you want"
  153.    FPUTLN 1,"graphics prompt'.  You need to change that setting in to 'N' in"
  154.    FPUTLN 1,"PCBSetup | Configuration Options | Configuration Switches."
  155.    FPUTLN 1,""
  156.    FCLOSE 1
  157.    MESSAGE 0,"SYSOP",PPEPATH()+PPENAME()+".PPE","Your Configuration","R",DATE()+2,FALSE,FALSE,temp_dir+"ANSI-D.$$$"
  158.    PRINTLN
  159.    PRINT "Do you want graphics (Enter)=no"
  160.    END
  161. ENDIF
  162.  
  163. ; /* If the user is capable of ANSI, then default for the "want graphics"
  164. ;    prompt will be Yes, otherwise, the default is set to "N".  The point
  165. ;    in asking the question is to enable the user to still choose if they
  166. ;    wish to see color or not, but if they do not know how to answer the
  167. ;    question, then the default will give them color if they are capable
  168. ;    of handling it.
  169.  
  170. IF (hasansi) THEN
  171.    
  172.    IF (hasrip) THEN
  173.       if (compatible) then
  174.          println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m     RIPscrip detected and it will be the default    "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m" 
  175.       else
  176.          ask=ask+"RIPscrip"
  177.       endif
  178.    ELSE      
  179.       if (compatible) then
  180.          println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m     ANSI detected and it will be the default    "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
  181.       else
  182.          ask=ask+"yes"
  183.       endif
  184.    ENDIF
  185.    
  186.    if (compatible) ask = ask + "default"
  187.    INPUTSTR ask,graphdef,07,6,"QSR"+YESCHAR()+NOCHAR(),LFBEFORE+LFAFTER+FIELDLEN+STACKED+UPCASE
  188.    
  189. ELSE
  190.    if (compatible) then
  191.       println cr_lf + "[* No graphics capabilities detected.  This will be the default *]"
  192.       ask = ask + "default"
  193.    else
  194.       ask=ask+"no"
  195.    endif
  196.    
  197.    INPUTSTR ask,graphdef,07,6,"QSR"+YESCHAR()+NOCHAR(),FIELDLEN+LFBEFORE+LFAFTER+STACKED+UPCASE
  198.    IF (graphdef="") graphdef=NOCHAR()
  199. ENDIF
  200.  
  201. ; /* Now that the "want graphics" prompt has been faked so that the default
  202. ;    value could be controlled, it is time to stuff the users response to
  203. ;    the fake prompt to the real prompt.  This inludes the "Q and NS"
  204. ;    parameters.                                                           */
  205.  
  206. if (instr(graphdef,"NS")) then
  207.    nonews="NS"
  208.    graphdef=left(graphdef,instr(graphdef,"NS")-1)+right(graphdef,len(graphdef)-(instr(graphdef,"NS")+1))
  209. endif   
  210.  
  211. if (instr(graphdef,yeschar())) ansi = yeschar()+";"
  212. if (instr(graphdef,nochar())) noansi = nochar()+";"
  213. if (instr(graphdef,"Q")) nowelc = "Q;"
  214. if (instr(graphdef,"R")) rip = "R;"
  215.  
  216. if (hasrip & noansi = "" & ansi = "") then
  217.    rip = "R;"
  218. else if (hasansi & noansi = "" & rip = "") then
  219.    ansi = yeschar()+";"
  220. endif
  221.  
  222. if (rip != "" & ansi != "") rip = ""
  223. if (rip != "" & noansi != "") rip = ""
  224. if (ansi != "" & noansi != "") ansi = ""
  225.  
  226. KBDSTUFF rip+ansi+noansi+nowelc+nonews
  227.  
  228. END                                    ; end of script
  229.