home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0923.lha
/
MagicPubName
/
MagicPubName.mod
< prev
next >
Wrap
Text File
|
1993-10-07
|
8KB
|
238 lines
(* ------------------------------------------------------------------------
:Program. MagicPubName.mod
:Contents. Brief, yet smart & versatile "Gimme that damn'
:Contents. PubScreen's name"- utility.
:Author. Franz Schwarz
:Copyright. Freeware (freely distributable, copyrighted software)
:Language. Oberon
:Translator. Amiga Oberon 3.0
:History. v1.0 fSchwarz 28-MΣr-93 (first public release)
:History. v1.1 fSchwarz 3-Jul-93 major internal changes, added
:History. ConsoleScr option, changed name from GetPubName to
:History. MagicPubName
:History. v1.2 fSchwarz 19-Jul-93 added ToFront feature
:History. v1.3 fSchwarz 27-Jul-93 added Quiet switch, now uses
:History. BlackMagic
:History. v1.3a fSchwarz 6-Aug-93 recompiled with BlackMagic1.8
:History. (ConsoleScr=Con/S was broken)
:Support. BlackMagic
:Address. Mⁿhlenstra▀e 2, D-78591 Durchhausen, Germany / R.F.A.
:Address. uucp: Franz.Schwarz@mil.ka.sub.org; Fido: 2:241/7506.18
:Remark. POSSIBLE ODD POINTERS TO ARRAY OF CHAR
:Remark. DON'T COMPILE WITH OddChk!
:Remark. Note the complexity of this utility - far beyond the
:Remark. usual trivial GetPubNames. An ideal complement for
:Remark. Bernhard M÷llemann's great ScreenManager.
:Usage. RequireVisible=RV/S,RequireFront=RF/S,Default/S,
:Usage. Shanghai/S,ConsoleScr=Con/S,ScreenName=Scr,Case/S,
:Usage. WBOnFailure=WBF/S,ToFront/S
------------------------------------------------------------------------ *)
(* $SET NODEBUG *)
MODULE MagicPubName;
IMPORT
e: Exec, d: Dos, I: Intuition, g: Graphics, u: Utility,
b: BlackMagic, o: OberonLib (* $IF DEBUG *) , NoGuru (* $END *) ;
TYPE
ArgsT = STRUCT
requireVisible: LONGINT;
requireFront : LONGINT;
default : LONGINT;
shanghai : LONGINT;
consoleScr : LONGINT;
screenName : e.STRPTR;
case : LONGINT;
wbOnFailure : LONGINT;
toFront : LONGINT;
quiet : LONGINT;
END;
CONST
ignoreRV = 0;
template = "RequireVisible=RV/S,RequireFront=RF/S,Default/S,Shanghai/S,ConsoleScr=Con/S,ScreenName=Scr,Case/S,WBOnFailure=WBF/S,ToFront/S,Quiet=Q/S";
verStr = "\000$VER: MagicPubName 1.3a (6.8.93) ⌐ Franz.Schwarz@mil.ka.sub.org - Freeware";
VAR
Rda : d.RDArgsPtr;
Args : ArgsT;
ScrNam : ARRAY I.maxPubScreenName+1 OF CHAR;
FirstScr, DefPubScr, Scr: I.ScreenPtr;
ShanghaiScr, ConsoleScr : I.ScreenPtr;
ScrList : e.ListPtr;
l : LONGINT;
modes : SET;
(* Finds a specific Screen in the system public screen list *)
PROCEDURE SearchPubScr (Scr: I.ScreenPtr; Name: e.STRPTR): I.ScreenPtr;
VAR
nd1 : I.PubScreenNodePtr;
i, passes : INTEGER;
BEGIN
IF (Scr = NIL) & (Name = NIL) THEN RETURN NIL; END;
IF (Name # NIL) & (Args.case = 0) THEN passes := 2; ELSE passes := 1; END;
FOR i:=1 TO passes DO
nd1 := ScrList.head;
WHILE nd1.node.succ # NIL DO
IF ~(I.psnfPrivate IN nd1.flags) THEN
LOOP
IF Args.requireVisible # 0 THEN
IF g.vpHide IN nd1.screen.viewPort.modes THEN EXIT; END;
END;
IF Scr # NIL THEN IF nd1.screen # Scr THEN EXIT; END; END;
IF Name # NIL THEN
CASE i OF
1: IF nd1.node.name^ # Name^ THEN EXIT; END; |
2: IF u.Stricmp (nd1.node.name^, Name^) # 0 THEN EXIT; END;
END;
END;
COPY (nd1.node.name^, ScrNam);
RETURN nd1.screen;
END;
END;
nd1 := nd1.node.succ;
END;
END;
RETURN NIL;
END SearchPubScr;
BEGIN
IF o.wbStarted OR (d.dos.lib.version < 37) THEN HALT (20); END;
Rda := d.ReadArgs (template, Args, NIL);
IF Rda # NIL THEN
IF (Args.case # 0) & (Args.screenName = NIL) THEN
IF d.SetIoErr (d.tooManyArgs) = 0 THEN END;
d.FreeArgs (Rda); Rda := NIL;
END;
END;
IF Rda # NIL THEN
IF (Args.requireVisible = 0) & (Args.default = 0) &
(Args.shanghai = 0) & (Args.screenName = NIL) &
(Args.consoleScr = 0) & (Args.requireFront = 0) THEN
Args.wbOnFailure := -1; (* due to compatability considerations *)
END;
DefPubScr := I.LockPubScreen (NIL);
I.UnlockPubScreen (NIL, DefPubScr);
IF Args.shanghai # 0 THEN
e.Forbid ();
modes := I.SetPubScreenModes ({});
IF I.SetPubScreenModes (modes) = {} THEN END;
e.Permit ();
IF ~(I.shanghai IN modes) THEN
ShanghaiScr := I.LockPubScreen ("Workbench");
ELSE
ShanghaiScr := I.LockPubScreen (NIL);
END;
I.UnlockPubScreen (NIL, ShanghaiScr);
END;
IF Args.consoleScr # 0 THEN ConsoleScr := b.GetTTYScreen (d.Input()); END;
IF Args.requireFront # 0 THEN FirstScr := I.int.firstScreen; END;
Scr := NIL;
IF Args.default # 0 THEN
IF DefPubScr # NIL THEN
Scr := DefPubScr;
ELSE
o.Result := 5;
END;
END;
IF Args.shanghai # 0 THEN
LOOP
IF ShanghaiScr # NIL THEN
IF Scr = NIL THEN EXIT; END;
IF Scr = ShanghaiScr THEN EXIT; END;
END;
o.Result := 5;
EXIT;
END;
IF o.Result = 0 THEN Scr := ShanghaiScr; END;
END;
IF Args.consoleScr # 0 THEN
LOOP
IF ConsoleScr # NIL THEN
IF Scr = NIL THEN EXIT; END;
IF Scr = ConsoleScr THEN EXIT; END;
END;
o.Result := 5;
EXIT;
END;
IF o.Result = 0 THEN Scr := ConsoleScr; END;
END;
IF Args.requireFront # 0 THEN
LOOP
IF FirstScr # NIL THEN
IF Scr = NIL THEN EXIT; END;
IF Scr = FirstScr THEN EXIT; END;
END;
o.Result := 5;
EXIT;
END;
IF o.Result = 0 THEN Scr := FirstScr; END;
END;
IF (Scr = NIL) & (Args.screenName = NIL) THEN
l := I.LockIBase (0);
Scr := I.int.firstScreen;
LOOP
IF Scr = NIL THEN EXIT; END;
IF ~(g.vpHide IN Scr.viewPort.modes) THEN
IF {I.publicScreen} = Scr.flags * I.screenType THEN EXIT; END;
IF {I.wbenchScreen} = Scr.flags * I.screenType THEN EXIT; END;
END;
Scr := Scr.nextScreen;
END;
I.UnlockIBase (l);
IF Scr = NIL THEN Scr := DefPubScr; END;
END;
ScrList := I.LockPubScreenList ();
IF ScrList # NIL THEN
IF SearchPubScr (Scr, Args.screenName) = NIL THEN o.Result := 5; END;
IF ScrNam = "" THEN o.Result := 5; END;
IF o.Result # 0 THEN
ScrNam := "";
IF Args.wbOnFailure # 0 THEN
Args.requireVisible := 0;
IF SearchPubScr (DefPubScr, NIL) = NIL THEN END;
END;
END;
I.UnlockPubScreenList ();
END;
IF ScrNam = "" THEN o.Result := 5; END;
IF o.Result # 0 THEN IF ScrNam = "" THEN
IF Args.wbOnFailure # 0 THEN ScrNam := "Workbench"; END;
END; END;
IF ScrNam # "" THEN
IF Args.toFront # 0 THEN
Scr := I.LockPubScreen (ScrNam);
IF Scr # NIL THEN
I.ScreenToFront (Scr); I.UnlockPubScreen (NIL, Scr);
ELSE
o.Result := 5;
END;
END;
IF Args.quiet = 0 THEN
d.PrintF ("%s", b.StrIndex (ScrNam, 0)); d.Flush (d.Output());
END;
END;
d.FreeArgs (Rda);
ELSE
d.PrintF ("%s failed.\n", b.StrIndex (verStr, 7));
o.Result := 20;
END; (* IF Rda # NIL *)
END MagicPubName.