home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
pcboard
/
grafd200.zip
/
GRAF-D.PPS
< prev
Wrap
Text File
|
1993-05-07
|
9KB
|
229 lines
;*****************************************************************************
;* *
;* ANSI DETECTION V2.0 *
;* *
;* 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.
INTEGER maxticks ; Stores the maximum number of ticks to wait for response.
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 ; temporary. Delete -- not needed. SLC 04/28/93
BOOLEAN compatible ; Used to determine is sysop wants to use compatible mode.
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
temp = "" ; Initialized to non null for WHILE
bkspace = chr(8)+chr(32)+chr(8) ; destructive backspace dwt
maxticks = 50 ; (50/18.2 seconds)
esc = chr(27)
cr_lf = chr(13)+chr(10)
; Analyze Command line passed
temp=gettoken()
while (temp != "") DO
if (mid(upper(temp),2,1) = "W") then
maxticks = mid(temp,instr(temp,":")+1,2)
if (maxticks < 1 | maxticks = "") maxticks=50
else if (mid(upper(temp),2,1) = "C") then
compatible = true
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
print esc+"[!"
print bkspace+bkspace+bkspace
print esc+" F"
print bkspace+bkspace+bkspace
print esc+"[6n"
print bkspace+bkspace+bkspace+bkspace
temp = chr(mgetbyte())
while (temp = "" & numticks <= maxticks) do
temp = chr(mgetbyte())
if (temp != "") then
recorded = true
else
delay 2
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 (temp = "") then
delay 2
temp = chr(mgetbyte())
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 (temp="") then
delay 2
temp = chr(mgetbyte())
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)
FCREATE 1,temp_dir+"ANSI-D.$$$",O_RW,S_DW
FPUTLN 1,"The PPE shown in the subject, could not run properly because you"
FPUTLN 1,"have your system configured to Default to Yes for the 'Do you want"
FPUTLN 1,"graphics prompt'. You need to change that setting in to 'N' in"
FPUTLN 1,"PCBSetup | Configuration Options | Configuration Switches."
FPUTLN 1,""
FCLOSE 1
MESSAGE 0,"SYSOP",PPEPATH()+PPENAME()+".PPE","Your Configuration","R",DATE()+2,FALSE,FALSE,temp_dir+"ANSI-D.$$$"
PRINTLN
PRINT "Do you want graphics (Enter)=no"
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"
INPUTSTR ask,graphdef,07,6,"QSR"+YESCHAR()+NOCHAR(),LFBEFORE+LFAFTER+FIELDLEN+STACKED+UPCASE
ELSE
if (compatible) then
println cr_lf + "[* No graphics capabilities detected. This will be the default *]"
ask = ask + "default"
else
ask=ask+"no"
endif
INPUTSTR ask,graphdef,07,6,"QSR"+YESCHAR()+NOCHAR(),FIELDLEN+LFBEFORE+LFAFTER+STACKED+UPCASE
IF (graphdef="") graphdef=NOCHAR()
ENDIF
; /* 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;"
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
END ; end of script