home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
VRAC
/
GRAFD220.ZIP
/
GRAF-D.PPS
< prev
next >
Wrap
Text File
|
1993-09-09
|
11KB
|
277 lines
;*****************************************************************************
;* *
;* ANSI DETECTION V2.1 *
;* *
;* written by: Steve Catmull *
;* additional coding: David Terry *
;* *
;* started: 04-26-93 *
;* *
;*****************************************************************************
BOOLEAN hasansi ; Result of ANSI - detection test (true or false)
BOOLEAN hasrip ; Result of ANSI - detection test (RIP & ANSI)
STRING graphdef ; Stores response to the "ask" prompt below
STRING ask ; Constant that contains "want graphics" minus default resp.
INTEGER numticks ; Used to store number of clock ticks that I have waited.
STRING maxticks ; Stores the maximum number of ticks to wait for response.
INTEGER waitlen ; Number of characters specified as wait time (2 or 3 digit)
STRING delayticks ; If no byte pending delay x ticks and try again.
STRING temp ; Stores the token of what user inputed.
STRING default_yes ; Used to store setting from PCBOARD.DAT for the default
STRING rest_ANSI ; Store rest of input buffer if any after ANSI CPR.
STRING temp_dir ; Temporary/work directory as defined in PCBSetup
STRING bkspace ; Sequence of characters for destructive backspace dwt
STRING esc ; Constant used instead of chr(27)
STRING cr_lf ; Constant used instead of chr(13)+chr(10)
BOOLEAN recorded ; Not really used anymore but leave it in here.
BOOLEAN compatible ; Used to determine is sysop wants to use compatible mode.
BOOLEAN debug ; Used for debugging (capturing incoming response)
STRING nonews ; For parsing out what user enters
STRING nowelc ; For parsing out what user enters
STRING ansi ; For parsing out what user enters
STRING rip ; For parsing out what user enters
STRING noansi ; For parsing out what user enters
STRING autoansr ; Used to skip graphics question if graphics detected
STRING rip_detect ; Used to disable RIPscrip checking. For those without RIP.
STRING allow_quick ; Used to enable or disable the "quick" login feature.
temp = "" ; Initialized to non null for WHILE
bkspace = chr(8)+chr(32)+chr(8) ; destructive backspace dwt
maxticks = 50 ; (50/18.2 seconds)
delayticks = 3 ; Wait 3 ticks if no input (when checking for response)
debug = false
esc = chr(27)
cr_lf = chr(13)+chr(10)
rip_detect = true ; Assume RIPscrip detection.
allow_quick="Q" ; Add to the valid entry string
; Analyze Command line passed
temp=gettoken()
while (temp != "") DO
if (mid(upper(temp),2,1) = "W") then
waitlen = len(temp)-instr(temp,":")
maxticks = mid(temp,instr(temp,":")+1,waitlen)
; if (maxticks < 1 | maxticks = "") maxticks=50
else if (mid(upper(temp),2,3) = "NOR") then
rip_detect = false
else if (mid(upper(temp),2,3) = "NOQ") then
allow_quick = ""
else if (mid(upper(temp),2,1) = "C") then
compatible = true
else if (mid(upper(temp),2,1) = "A") then
autoansr = true
else if (mid(upper(temp),2,5) = "DELAY") then
waitlen = len(temp)-instr(temp,":")
delayticks = mid(temp,instr(temp,":")+1,waitlen)
else if (mid(upper(temp),2,5) = "DEBUG") then
debug = true
fappend 1, ppepath() + "DEBUG.GRF", o_rw, s_dn
if (ferr(1)) sprintln "@X8CUnable to write to debug log file."
fputln 1
fputln 1
fputln 1, "GRAF-D Debug : ", DATE(), " ", TIME()
fputln 1
fputln 1, "allow_quick : ", allow_quick
fputln 1, "autoansr : ", autoansr
fputln 1, "compatible : ", compatible
fputln 1, "delayticks : ", delayticks
fputln 1, "maxticks : ", maxticks
fputln 1, "rip_detect : ", rip_detect
fputln 1, "------------------------------------------"
endif
temp=gettoken()
endwhile
temp="" ; Return temp how we found it.
; /* Notifying the user that ANSI detection is being processed. This keeps
; them entertainment while the "ansitime" pause is being executed. */
PRINTLN "Testing your system capability..." ; Amusing the caller.
; /* If you user is connected locally then default autoamtically to ANSI
; capable. Otherwise, send out the escape sequence to get the current
; cursor position. Immediately follow that with a bunch of backspace
; space backspace sequences in case they do not have the ability to
; interpret ANSI. Otherwise, it may be left on the screen. Finally,
; wait for the and ESC followed by a left bracket to be returned. This
; is the only constant part of the ANSI detection that can be tested.
; If that sequence is returned within ANSITIME seconds, then the caller
; is considered to be ANSI capable and the HASANSI variable shows it.
;
; NOTE: Evidently some terminal programs are quite lazy in returning
; the response to the ANSI detection test. This PPE does not
; attempt to make any accomodations for those programs. Instead,
; it waits "ANSITIME" seconds and then continues with the best that
; has been determined by that time. */
if (onlocal()) then
hasansi=TRUE
else
if (rip_detect) then ; If SysOp desires RIPscrip
mprint esc+"[!" ; send auto detection sequence.
mprint bkspace+bkspace+bkspace
endif
mprint esc+" F"
mprint bkspace+bkspace+bkspace
mprint esc+"[6n"
mprint bkspace+bkspace+bkspace+bkspace
temp = chr(mgetbyte())
if (debug) fput 1, temp
while (temp = "" & numticks <= maxticks) do
temp = chr(mgetbyte())
if (debug) fput 1, temp
if (temp != "") then
recorded = true
else
delay delayticks
numticks = numticks + 2
endif
endwhile
if (temp = "R") then
while (temp != "" | len(rest_ansi) < 9) do
rest_ansi=rest_ansi+temp
temp=chr(mgetbyte())
if (debug) fput 1, temp
if (temp = "") then
delay delayticks
temp = chr(mgetbyte())
if (debug) fput 1, temp
endif
endwhile
if (left(rest_ansi,3)="RIP") then
hasrip=TRUE
hasansi=TRUE
endif
else if (temp = esc) then
while (temp != "") do
rest_ansi=rest_ansi+temp
temp=chr(mgetbyte())
if (debug) fput 1, temp
if (temp="") then
delay delayticks
temp = chr(mgetbyte())
if (debug) fput 1, temp
endif
endwhile
tokenize rest_ansi
temp = gettoken()
temp = mid(temp,2,len(temp-1))
if ((temp >= 0 | temp <= 80) & (right(GETTOKEN(),1)="R")) then
hasansi=TRUE
else
hasansi=FALSE
endif
endif
endif
; /* Assign ASK variable to prompt used for ANSI. The default if enter is
; pressed is ommitted so that it may be built according to their ANSI
; capabilities. */
ask = "Do you want graphics (Enter)="
; /* Read line #257 in PCBOARD.DAT to find out what the default for the
; "Do you want graphics" prompt is. Store the result in DEFAULT_YES.
default_yes = READLINE(PCBDAT(),257)
; /* If the default to the "Do you want graphics prompt is "Yes", then
; inform the sysop via a message that the system is configured improperly. */
IF (default_yes) THEN
temp_dir = READLINE(PCBDAT(),179)
SPRINTLN
SPRINTLN "┌───────────────────────────────────────────────────────────────────┐"
SPRINTLN "│ Your system is improperly configured for use with the GRAF-D.PPE │"
SPRINTLN "│ file. You have configured it to default to Yes for the 'Do you │"
SPRINTLN "│ want graphics' prompt. You need to change that setting to 'N' in │"
SPRINTLN "│ PCBSetup | Configuration Options | Configuration Switches. │"
SPRINTLN "└───────────────────────────────────────────────────────────────────┘"
SPRINTLN
PRINT "Do you want graphics (Enter)=no"
if (debug) fclose 1
END
ENDIF
; /* If the user is capable of ANSI, then default for the "want graphics"
; prompt will be Yes, otherwise, the default is set to "N". The point
; in asking the question is to enable the user to still choose if they
; wish to see color or not, but if they do not know how to answer the
; question, then the default will give them color if they are capable
; of handling it.
IF (hasansi) THEN
IF (hasrip) THEN
if (compatible) then
println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m RIPscrip detected and it will be the default "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
else
ask=ask+"RIPscrip"
endif
ELSE
if (compatible) then
println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m ANSI detected and it will be the default "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
else
ask=ask+"yes"
endif
ENDIF
if (compatible) ask = ask + "default"
ELSE
if (compatible) then
println cr_lf + "[* No graphics capabilities detected. This will be the default *]"
ask = ask + "default"
else
ask=ask+"no"
endif
ENDIF
if ((autoansr & ! hasansi) | !autoansr) then ; Skip if user has ANSI and AUTO stuff is enabled
INPUTSTR ask,graphdef,07,6,"SR"+allow_quick,FIELDLEN+LFBEFORE+LFAFTER+STACKED+UPCASE+YESNO
IF (graphdef="" & !hasansi) graphdef=NOCHAR()
; /* Now that the "want graphics" prompt has been faked so that the default
; value could be controlled, it is time to stuff the users response to
; the fake prompt to the real prompt. This inludes the "Q and NS"
; parameters. */
if (instr(graphdef,"NS")) then
nonews="NS"
graphdef=left(graphdef,instr(graphdef,"NS")-1)+right(graphdef,len(graphdef)-(instr(graphdef,"NS")+1))
endif
if (instr(graphdef,yeschar())) ansi = yeschar()+";"
if (instr(graphdef,nochar())) noansi = nochar()+";"
if (instr(graphdef,"Q")) nowelc = "Q;"
if (instr(graphdef,"R")) rip = "R;"
endif
if (hasrip & noansi = "" & ansi = "") then
rip = "R;"
else if (hasansi & noansi = "" & rip = "") then
ansi = yeschar()+";"
endif
if (rip != "" & ansi != "") rip = ""
if (rip != "" & noansi != "") rip = ""
if (ansi != "" & noansi != "") ansi = ""
KBDSTUFF rip+ansi+noansi+nowelc+nonews
if (debug) fclose 1
END ; end of script