home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Micro R&D 1
/
MicroRD-CD-ROM-Vol1-1994.iso
/
os20
/
cli
/
getpubname.lha
/
GetPubName
/
GetPubName.mod
< prev
next >
Wrap
Text File
|
1992-09-26
|
4KB
|
122 lines
(*=============================================================================
:Program. GetPubName
:Contents. An easy Program, which only returns the Name of the frontmost
:Contents. PubScreen
:Author. Michael `Mick' Hohmann
:Address. Carl-Schilling-Str. 10; 8701 Kirchheim
:Address. UUCP: mickh@imart.franken.de
:Phone. 09 31 / 54 1 55
:Copyright. Freely Distributable
:Language. Oberon
:Translator. AmigaOberon 2.39d
:Imports. MoreIntuition
:History. v0.01 just did an WriteString -- nothing else
:History. v1.1 finished -- I hope so ;-))
:History. v1.2 Always creates an ENV-Var -- Bug Fixed
:History. v1.3 translated to Oberon
:History. v1.4 again some Bugfixes -- thanx to `tron'
:Thanx. done WITH much much Help from Jürgen Weinelt
=============================================================================*)
MODULE GetPubName;
IMPORT
D:=Dos,
E:=Exec,
I:=Intuition,
MI:=MoreIntuition,
OL:=OberonLib,
SYSTEM;
CONST
strLen = 80;
argTemplate = "ENV=ENVIRONMENT,LOC=LOCAL/S,HELP/S";
oProgName = "GetPubName 1.4";
date = "(Saturday 26 Sep 1992)";
versionString = "$VER: GetPubName 1.4 (Saturday 26 Sep 1992)";
need20 = "This programm needs Kick 2.04! Sorry!";
TYPE
String = ARRAY 256 OF CHAR;
StringPtr = POINTER TO String;
PubString = ARRAY I.maxPubScreenName+1 OF CHAR;
DosArgs = STRUCT
env : StringPtr;
local : LONGINT;
help : LONGINT
END;
VAR
envName : ARRAY strLen OF CHAR;
pubScrName : PubString;
activeScreen : I.ScreenPtr;
dArgs : DosArgs;
envType : LONGSET;
progName : ARRAY 33 OF CHAR;
BEGIN
(** Das Programm laeuft nur >= Kick 2.x **)
IF OL.wbStarted THEN HALT(20); END; (* sinnlos von WB *)
IF D.dos.lib.version < 37 THEN
IF D.Write(D.Output(),need20,SIZE(need20))=0 THEN END;
HALT(20);
END;
SYSTEM.SETREG(0,SYSTEM.ADR(versionString));
IF ~D.GetProgramName(progName,30) THEN progName:=oProgName; END;
(** Initialisierung der Variablen **)
envName:="FrontPubName";
dArgs:=DosArgs(NIL,0,0);
pubScrName:="";
envType:=LONGSET{};
activeScreen:=MI.LockFrontPubScr(pubScrName); (** Den vordersten PubScreen, oder die WB locken **)
(** Get Arguments from CLI and write the Name to StdOut or to an ENV-Var **)
IF D.ReadArgs(argTemplate,dArgs,NIL)#NIL THEN
IF dArgs.help#0 THEN
IF D.WriteStr("\n\[33m") THEN END;
IF D.WriteStr(oProgName) THEN END;
IF D.WriteStr("\[0m © 1992 by Michael `Mick' Hohmann ") THEN END;
IF D.WriteStr(date) THEN END;
IF D.WriteStr("\n\nGetPubName returns the Name of the FrontMost PublicScreen\neither to StdOut or if specified as an Global-Variable.\n\n") THEN END;
HALT(0)
END;
IF dArgs.env#NIL THEN
COPY(dArgs.env^,envName)
ELSE
IF D.WriteStr(pubScrName) THEN END;
HALT(0)
END;
IF dArgs.local#0 THEN
INCL(envType,D.localOnly)
ELSE
INCL(envType,D.globalOnly)
END;
ELSE
IF D.WriteStr("\n== Command line syntax error ==\n") THEN END;
HALT(15)
END;
IF ~D.SetVar(envName,pubScrName,SIZE(pubScrName),envType) THEN
IF D.WriteStr("\n== Sorry, couldn't create the ENV-Variable ==\n") THEN END;
HALT(15)
END
CLOSE
IF activeScreen#NIL THEN
I.UnlockPubScreen(NIL,activeScreen);
END;
END GetPubName.