home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / VRAC / GRAFD220.ZIP / GRAF-D.PPS < prev    next >
Text File  |  1993-09-09  |  11KB  |  277 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. STRING maxticks    ; Stores the maximum number of ticks to wait for response.
  19. INTEGER waitlen     ; Number of characters specified as wait time (2 or 3 digit)
  20. STRING delayticks  ; If no byte pending delay x ticks and try again.
  21. STRING  temp        ; Stores the token of what user inputed.
  22. STRING  default_yes ; Used to store setting from PCBOARD.DAT for the default
  23. STRING  rest_ANSI   ; Store rest of input buffer if any after ANSI CPR.
  24. STRING  temp_dir    ; Temporary/work directory as defined in PCBSetup
  25. STRING  bkspace     ; Sequence of characters for destructive backspace  dwt
  26. STRING  esc         ; Constant used instead of chr(27)
  27. STRING  cr_lf       ; Constant used instead of chr(13)+chr(10)
  28.  
  29. BOOLEAN recorded    ; Not really used anymore but leave it in here.
  30. BOOLEAN compatible  ; Used to determine is sysop wants to use compatible mode.
  31. BOOLEAN debug       ; Used for debugging (capturing incoming response)
  32. STRING  nonews      ; For parsing out what user enters
  33. STRING  nowelc      ; For parsing out what user enters
  34. STRING  ansi        ; For parsing out what user enters
  35. STRING  rip         ; For parsing out what user enters
  36. STRING  noansi      ; For parsing out what user enters
  37. STRING  autoansr    ; Used to skip graphics question if graphics detected
  38. STRING  rip_detect  ; Used to disable RIPscrip checking.  For those without RIP.
  39. STRING  allow_quick ; Used to enable or disable the "quick" login feature.
  40.  
  41. temp    = ""                             ; Initialized to non null for WHILE
  42. bkspace = chr(8)+chr(32)+chr(8)          ; destructive backspace  dwt
  43. maxticks = 50   ; (50/18.2 seconds)
  44. delayticks = 3  ; Wait 3 ticks if no input (when checking for response)
  45. debug = false
  46. esc = chr(27)
  47. cr_lf = chr(13)+chr(10)
  48. rip_detect = true                        ; Assume RIPscrip detection.
  49. allow_quick="Q"                          ; Add to the valid entry string
  50.  
  51. ; Analyze Command line passed
  52.  
  53. temp=gettoken()
  54. while (temp != "") DO
  55.    if (mid(upper(temp),2,1) = "W") then
  56.       waitlen = len(temp)-instr(temp,":")
  57.       maxticks = mid(temp,instr(temp,":")+1,waitlen)
  58. ;      if (maxticks < 1 | maxticks = "")  maxticks=50
  59.    else if (mid(upper(temp),2,3) = "NOR") then
  60.       rip_detect = false
  61.    else if (mid(upper(temp),2,3) = "NOQ") then
  62.       allow_quick = ""
  63.    else if (mid(upper(temp),2,1) = "C") then
  64.       compatible = true
  65.    else if (mid(upper(temp),2,1) = "A") then
  66.       autoansr = true
  67.    else if (mid(upper(temp),2,5) = "DELAY") then
  68.       waitlen = len(temp)-instr(temp,":")
  69.       delayticks = mid(temp,instr(temp,":")+1,waitlen)
  70.    else if (mid(upper(temp),2,5) = "DEBUG") then
  71.       debug = true
  72.       fappend 1, ppepath() + "DEBUG.GRF", o_rw, s_dn
  73.       if (ferr(1)) sprintln "@X8CUnable to write to debug log file."
  74.       fputln 1
  75.       fputln 1
  76.       fputln 1, "GRAF-D Debug : ", DATE(), " ", TIME()
  77.       fputln 1
  78.       fputln 1, "allow_quick : ", allow_quick
  79.       fputln 1, "autoansr    : ", autoansr
  80.       fputln 1, "compatible  : ", compatible
  81.       fputln 1, "delayticks  : ", delayticks
  82.       fputln 1, "maxticks    : ", maxticks
  83.       fputln 1, "rip_detect  : ", rip_detect
  84.       fputln 1, "------------------------------------------"
  85.    endif
  86.    temp=gettoken()
  87. endwhile
  88. temp="" ; Return temp how we found it.
  89.  
  90.  
  91. ; /* Notifying the user that ANSI detection is being processed.  This keeps
  92. ;    them entertainment while the "ansitime" pause is being executed.  */
  93.  
  94. PRINTLN "Testing your system capability..."   ; Amusing the caller.
  95.  
  96. ; /* If you user is connected locally then default autoamtically to ANSI
  97. ;    capable.  Otherwise, send out the escape sequence to get the current
  98. ;    cursor position.  Immediately follow that with a bunch of backspace
  99. ;    space backspace sequences in case they do not have the ability to
  100. ;    interpret ANSI.  Otherwise, it may be left on the screen.  Finally,
  101. ;    wait for the and ESC followed by a left bracket to be returned.  This
  102. ;    is the only constant part of the ANSI detection that can be tested.
  103. ;    If that sequence is returned within ANSITIME seconds, then the caller
  104. ;    is considered to be ANSI capable and the HASANSI variable shows it.
  105. ;
  106. ;    NOTE:  Evidently some terminal programs are quite lazy in returning
  107. ;           the response to the ANSI detection test.  This PPE does not
  108. ;           attempt to make any accomodations for those programs.  Instead,
  109. ;           it waits "ANSITIME" seconds and then continues with the best that
  110. ;           has been determined by that time.                            */
  111.  
  112.  
  113. if (onlocal()) then
  114.    hasansi=TRUE
  115. else
  116.    if (rip_detect) then                     ; If SysOp desires RIPscrip
  117.       mprint esc+"[!"                       ; send auto detection sequence.
  118.       mprint bkspace+bkspace+bkspace
  119.    endif
  120.    mprint esc+" F"
  121.    mprint bkspace+bkspace+bkspace
  122.    mprint esc+"[6n"
  123.    mprint bkspace+bkspace+bkspace+bkspace
  124.  
  125.    temp = chr(mgetbyte())
  126.    if (debug) fput 1, temp
  127.  
  128.    while (temp = "" & numticks <= maxticks) do
  129.       temp = chr(mgetbyte())
  130.       if (debug) fput 1, temp
  131.       if (temp != "") then
  132.          recorded = true
  133.       else
  134.          delay delayticks
  135.          numticks = numticks + 2
  136.       endif
  137.    endwhile
  138.  
  139.    if (temp = "R") then
  140.       while (temp != "" | len(rest_ansi) < 9) do
  141.          rest_ansi=rest_ansi+temp
  142.          temp=chr(mgetbyte())
  143.          if (debug) fput 1, temp
  144.          if (temp = "") then
  145.            delay delayticks
  146.            temp = chr(mgetbyte())
  147.            if (debug) fput 1, temp
  148.          endif
  149.       endwhile
  150.       if (left(rest_ansi,3)="RIP") then
  151.          hasrip=TRUE
  152.          hasansi=TRUE
  153.       endif
  154.    else if (temp = esc) then
  155.       while (temp != "") do
  156.          rest_ansi=rest_ansi+temp
  157.          temp=chr(mgetbyte())
  158.          if (debug) fput 1, temp
  159.          if (temp="") then
  160.             delay delayticks
  161.             temp = chr(mgetbyte())
  162.             if (debug) fput 1, temp
  163.          endif
  164.       endwhile
  165.       tokenize rest_ansi
  166.       temp = gettoken()
  167.       temp = mid(temp,2,len(temp-1))
  168.       if ((temp >= 0 | temp <= 80) & (right(GETTOKEN(),1)="R")) then
  169.          hasansi=TRUE
  170.       else
  171.          hasansi=FALSE
  172.       endif
  173.    endif
  174. endif
  175.  
  176.  
  177. ; /* Assign ASK variable to prompt used for ANSI.  The default if enter is
  178. ;    pressed is ommitted so that it may be built according to their ANSI
  179. ;    capabilities.                                                       */
  180.  
  181. ask = "Do you want graphics (Enter)="
  182.  
  183. ; /* Read line #257 in PCBOARD.DAT to find out what the default for the
  184. ;    "Do you want graphics" prompt is.  Store the result in DEFAULT_YES.
  185.  
  186. default_yes = READLINE(PCBDAT(),257)
  187.  
  188. ; /* If the default to the "Do you want graphics prompt is "Yes", then
  189. ;    inform the sysop via a message that the system is configured improperly. */
  190.  
  191. IF (default_yes) THEN
  192.    temp_dir = READLINE(PCBDAT(),179)
  193.    SPRINTLN
  194.    SPRINTLN "┌───────────────────────────────────────────────────────────────────┐"
  195.    SPRINTLN "│ Your system is improperly configured for use with the GRAF-D.PPE  │"
  196.    SPRINTLN "│ file.  You have configured it to default to Yes for the 'Do you   │"
  197.    SPRINTLN "│ want graphics' prompt.  You need to change that setting to 'N' in │"
  198.    SPRINTLN "│ PCBSetup | Configuration Options | Configuration Switches.        │"
  199.    SPRINTLN "└───────────────────────────────────────────────────────────────────┘"
  200.    SPRINTLN
  201.    PRINT "Do you want graphics (Enter)=no"
  202.    if (debug) fclose 1
  203.    END
  204. ENDIF
  205.  
  206. ; /* If the user is capable of ANSI, then default for the "want graphics"
  207. ;    prompt will be Yes, otherwise, the default is set to "N".  The point
  208. ;    in asking the question is to enable the user to still choose if they
  209. ;    wish to see color or not, but if they do not know how to answer the
  210. ;    question, then the default will give them color if they are capable
  211. ;    of handling it.
  212.  
  213. IF (hasansi) THEN
  214.  
  215.    IF (hasrip) THEN
  216.       if (compatible) then
  217.          println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m     RIPscrip detected and it will be the default    "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
  218.       else
  219.          ask=ask+"RIPscrip"
  220.       endif
  221.    ELSE
  222.       if (compatible) then
  223.          println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m     ANSI detected and it will be the default    "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
  224.       else
  225.          ask=ask+"yes"
  226.       endif
  227.    ENDIF
  228.  
  229.    if (compatible) ask = ask + "default"
  230.  
  231. ELSE
  232.    if (compatible) then
  233.       println cr_lf + "[* No graphics capabilities detected.  This will be the default *]"
  234.       ask = ask + "default"
  235.    else
  236.       ask=ask+"no"
  237.   endif
  238. ENDIF
  239.  
  240. if ((autoansr & ! hasansi)  | !autoansr) then         ; Skip if user has ANSI and AUTO stuff is enabled
  241.  
  242.    INPUTSTR ask,graphdef,07,6,"SR"+allow_quick,FIELDLEN+LFBEFORE+LFAFTER+STACKED+UPCASE+YESNO
  243.    IF (graphdef="" & !hasansi) graphdef=NOCHAR()
  244.  
  245.    ; /* Now that the "want graphics" prompt has been faked so that the default
  246.    ;    value could be controlled, it is time to stuff the users response to
  247.    ;    the fake prompt to the real prompt.  This inludes the "Q and NS"
  248.    ;    parameters.                                                           */
  249.  
  250.    if (instr(graphdef,"NS")) then
  251.       nonews="NS"
  252.       graphdef=left(graphdef,instr(graphdef,"NS")-1)+right(graphdef,len(graphdef)-(instr(graphdef,"NS")+1))
  253.    endif
  254.  
  255.    if (instr(graphdef,yeschar())) ansi = yeschar()+";"
  256.    if (instr(graphdef,nochar())) noansi = nochar()+";"
  257.    if (instr(graphdef,"Q")) nowelc = "Q;"
  258.    if (instr(graphdef,"R")) rip = "R;"
  259.  
  260. endif
  261.  
  262.    if (hasrip & noansi = "" & ansi = "") then
  263.       rip = "R;"
  264.    else if (hasansi & noansi = "" & rip = "") then
  265.       ansi = yeschar()+";"
  266.    endif
  267.  
  268.    if (rip != "" & ansi != "") rip = ""
  269.    if (rip != "" & noansi != "") rip = ""
  270.    if (ansi != "" & noansi != "") ansi = ""
  271.  
  272. KBDSTUFF rip+ansi+noansi+nowelc+nonews
  273.  
  274. if (debug) fclose 1
  275.  
  276. END                                    ; end of script
  277.