home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Press 1997 July
/
Sezamfile97_1.iso
/
msdos
/
clipper
/
c50xp300.a01
/
XPNGDEMO.ARJ
/
NGVIEW.PRG
< prev
Wrap
Text File
|
1992-10-01
|
7KB
|
300 lines
* ------------------------------------------------------------------------
* File........: NGVIEW.PRG
* Author......: Pepijn Smits
* Copyright...: (c)1992, by "Softwarebureau Pepijn Smits", Rotterdam.
* Date........: August 1992
* Compiler....: Clipper 5.01, Compile with /m /l /n /v
* Notes.......: Norton Guides Viewer: Demonstrates the use of the
* Expand Library.
*
* Please note also that the program isn't quite ready yet. It's a good
* demo of what is possible with the NG routines, The demo itself is not
* very well behaved. Some ShortCuts, for instance, do not work as expected.
* Feel free to adapt the Demo where necessary, it's intended as a Demo and
* not much more.
* ------------------------------------------------------------------------
#include "INKEY.CH"
#xcommand MenuColor() => setColor(if(IsColor(),"N/W,W+/R,,R/W,GR+/R","W/N,N/W,,W+/N,N/W")) ;
; XPcolor()
#xcommand NormColor() => setColor(if(isColor(),"BG+/B,N/BG,,GR+/B,W+/BG","N/W,W/N,,N/W,W+/N")) ;
; XPcolor()
Static M := { {'≡', {'~A~bout..',;
'Display some version information',;
{||About()} },;
{'~H~elp ~F1~',;
'Display Help for this program',;
{||Help()} },;
{'~C~redits ~F3~',;
'Display database credits',;
{||Credits()} },;
{'E~x~it ~Alt-X~',;
'Quit the program',;
{||Stop()} } } }
Procedure Main()
Local i,j,n
Local cFile := Upper(AllTrim(XPcommandLine()))
if At('.',cFile)==0
cFile+=".NG"
end
if Empty(cFile)
?? 'Norton Guides Viewer v1.00, Written by Pepijn Smits, 1992.'
?
? 'Usage: NGview <NortonGuideDatabase>'
?
quit
end
if NGopen(cFile)
MenuColor()
DispBox(0,0,maxRow(),MaxCol(),"░░░░░░░░░")
if NGmenus() > 0
for i := 1 to NGmenus()
aAdd(m,{NGmenuTitle(i)})
for j := 1 to NGmenuCount(i)
aAdd(m[i+1],;
{ NGmenuLabel(i,j),;
NGname() +' » '+ NGmenuTitle(i) + ' » ' +NGmenuLabel(i,j),;
{||HandleMenu()} })
next
next
else
aAdd(m,{NGname(),{NGname(),NGname()+' » (No menu entries)',{||HandleMenu()}}})
end
XPpullInit(m,{|cMsg|HandleMsg(cMsg)})
While .t.
Eval(XPpullMenu())
end
else
?? 'Norton Guides Viewer v1.00, Written by Pepijn Smits, 1992.'
?
? 'Error: File not Found or not a valid Norton Guide: '+cFile
?
end
quit
Return
Function HandleMsg(cMsg)
XPmsg(PadR(" "+cMsg,69)+" ~│~ NGview")
Return (NIL)
Function Stop()
setColor('')
cls
quit
Return (NIL)
Function About()
Local c := SetColor()
MenuColor()
XPalert('About ~NGview~',;
';This program is written in ~Clipper 5.01~;'+;
'using the ~Expand Library v3.00~ which contains routines;'+;
'to read and interpret ~Norton Guides~.;;'+;
'Copyright (c) 1992, Written by Pepijn Smits')
SetColor(c)
XPcolor()
Return (NIL)
Function Help()
Local c := SetColor()
MenuColor()
XPalert("Help for ~NGview~",;
';~Esc~ Back-Up one Level (does not quit Application though) '+;
';~Enter~ Select the currently High-lighted item '+;
';~Cursor~ Move the selection Bar, dos scroll in text entries '+;
';~F2~ Display the List of Related Topics (in text entries) '+;
';~F3~ Display the Database credits '+;
';~F10~ Go directly to the menu options (from any entry) '+;
';~+~ Go to the next text entry (only in text entries) '+;
';~-~ Go to the previous text entry (only in text entries) '+;
';~Alt-X~ Quit the Application at once ')
SetColor(c)
XPcolor()
Return (NIL)
Function Credits()
Local c := SetColor()
Local s := ""
MenuColor()
aEval(NGcredit(),{|l|s+=PadR(l,66)+';'})
XPalert("Database credits",;
";Current database: ~"+NGname()+"~;;"+s)
SetColor(c)
XPcolor()
Return (NIL)
Function Info()
/**
* "Non Documented", Alt-I displays some Guide Entry information
*/
Local c := SetColor()
MenuColor()
XPalert("Guide ~Info~",;
";Info about the current Entry:;"+;
";NGnext : ~"+Str(NGnext(),8) +;
";NGprev : ~"+Str(NGprev(),8) +;
";NGmenuParent[1] : ~"+Str(NGmenuParent()[1],8)+;
";NGmenuParent[2] : ~"+Str(NGmenuParent()[2],8)+;
";NGparent[1] : ~"+Str(NGparent()[1],8)+;
";NGparent[2] : ~"+Str(NGparent()[2],8) )
SetColor(c)
XPcolor()
Return (NIL)
Function HandleTitle()
Local i := NGmenuParent()[1]
Local j := NGmenuParent()[2]
Local s := NGname()+' » ' +;
NGmenuTitle(i)+;
' » '+;
NGmenuLabel(i,j)
if NGparent()[1] <> -1
s+=" » .."
end
XPdisplay(1,1,replicate('═',MaxCol()-1))
XPcenter(1,' '+s+' ')
Return (NIL)
Function HandleMenu()
Local i := XPcurrentX()-1 // Get Current Menu, which is Menu's X-1
Local j := XPcurrentY() // Get Current Menu Entry, which is Y
// Get Entry (is 378 when No menus)
Local e := if(NGmenus()>0,NGmenuEntry(i,j),378)
Local n := 1
Local c := SetColor()
NormColor()
While e <> -1
NGmsg(" Loading Entry, please wait..")
Scroll(1,0,MaxRow()-1,MaxCol(),0)
DispBox(1,0,MaxRow()-1,MaxCol(),2)
e := HandleEntry(e,@n)
end
XPcurrentX( NGmenuParent()[1]+1 )
XPcurrentY( NGmenuParent()[2] )
SetColor(c)
XPcolor()
Return (NIL)
Function HandleEntry(e,n)
Local x := NGtype(e)
Local nEntry := e
Local a,s,i
if x = 0
a := NGshort(e)
HandleTitle()
NGmsg(" ~F1~-Help, ~F3~-Credits ~F10~-Back ~Up~-~Dn~-~PgUp~-~PgDn~-~Home~-~End~-Move, ~Alt-X~-Quit")
XPmouseChoice(2,1,MaxRow()-2,MaxCol()-1,;
{|x|if(x=0,len(a),a[x,1])},;
{|nMode,i|ShortKey(nMode,i,a,@nEntry,@n)},n+1)
elseif x = 1
s := NGlong(e)
HandleTitle()
NGmsg(" ~F1~-Help, ~F2~-See Also, ~F3~-Credits ~Up~-~Dn~-~PgUp~-~PgDn~-~Home~-~End~-Move, ~Alt-X~-Quit")
XPmouseBrowse(2,1,MaxRow()-2,maxCol()-1,s,;
{|nMode|LongKey(nMode,@nEntry,@n)})
end
Return (nEntry)
Function ShortKey(nMode,i,a,nEntry,n)
Local nKey := LastKey()
n := 1
do case
case nKey == K_ALT_X
Stop()
case nKey == K_ALT_I
Info()
case nKey == K_F1
Help()
case nKey == K_F3
Credits()
case nKey == K_F10
nEntry := -1
nKey := K_ESC
case nKey == K_ENTER
if a[i,2] <> -1
nEntry := a[i,2]
else
nKey := 32
end
case nKey == K_ESC
if NGparent()[1] <> -1
nEntry := NGparent()[1]
n := NGparent()[2]
else
nEntry := -1
end
endcase
Return (nKey)
Function LongKey(nMode,nEntry,n)
Local nKey := LastKey()
do case
case nKey == K_ALT_X
Stop()
case nKey == K_ALT_I
info()
case nKey == K_F1
Help()
case nKey == K_F2
nKey := LongSeeAlso(@nEntry)
case nKey == K_F3
Credits()
case nKey == K_F10
nEntry := -1
nKey := K_ESC
case nKey == K_ESC
nEntry := NGparent()[1]
if nEntry <> -1
n := NGparent()[2]
end
case nKey == Asc('-')
if NGnext() <> -1
nEntry := NGnext()
nKey := K_ESC
end
case nKey == Asc('+')
if NGprev() <> -1
nEntry := NGprev()
nKey := K_ESC
end
endcase
Return (nKey)
Function LongSeeAlso(nEntry)
Local nKey := 0
Local a := NGseeAlso(nEntry)
Local aMsg := {}
Local c := SetColor()
Local i
MenuColor()
if (a == NIL)
a := {}
end
if len(a) == 0
XPalert('See Also',";Sorry, There are no ~See Also~ References here;")
else
aEval(a,{|e|aAdd(aMsg,e[1])})
i := XPboxMenu("See Also",aMsg)
if i > 0
nEntry := a[i,2]
nKey := K_ESC
end
end
SetColor(c)
XPcolor()
Return (nKey)
Function NGmsg(s)
/***
* We've got to fool with the Color here..
*/
Local c := SetColor()
MenuColor()
XPmsg(s)
SetColor(c)
XPcolor()
Return (NIL)