Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/callmi.sim
There is 1 other file named callmi.sim in the archive. Click here to see a list.
! PROCEDURE CALLMIC will enable the SIMULA programmer to do
! almost anything from his (her) SIMULA program.
! The use of this procedure depends on the existence of
! the MIC system residing on the SYS: area.
!
! The procedure CALLMIC is used in the following manner -
!
! The user first creates a file MIC.TMP containing ordinary DEC-10
! commands like .DELETE *.BAK
!		.RUN ABC
!		.COJOB=A.MIC parm1
!		./ABCMIC
! etc.
!
! The call CALLMIC("MIC.TMP","SAV.TMP");
! will then use MIC.TMP for a MIC run.
! The files MICFILE,SAVFILE will - if possible - be deleted at return.
! If the file name for the MIC file contains a protection code
! with 1st digit equal to 2 (i.e. "MIC.TMP<277>"), then the MIC
! execution will be silent.
! Note, however, that CALLMIC then will be unable to delete
! the file afterwards.
!	(The message "? MACRO FILE NOT FOUND." will follow at the end of
!	the SIMULA program. Please ignore that message.)
! Alternatively the user may start the MIC
! file with: .SILENCE
!
! If the 2nd parameter =/= NOTEXT the MIC session will end by
! returning to the point of CALLMIC call.
! This is done in the following way.
! CALLMIC will save current program in file SAVFILE and end
! the MIC session with .RUN "SAVFILE".
!
!
! Otherwise, if SAVFILE == NOTEXT, no return to the calling
! program will occur.
!
! !!!!	The same restrictions as for SAVE are valid. Thus:
! !!!!  Only Sysin and Sysout may be open when calling CALLMIC. !!!!
! !!!!  Sysin and Sysout must be the user's TTY.		!!!!
!	Note that you may close Outfiles before calling CALLMIC
!	and then open again with "file.ext/access:append".
!	Infiles are more difficult to handle - you may keep count
!	of how many lines you have read before closing and then
!	read past the part already read after opening again.
!	Directfiles gives no problems here of course - just
!	save current Location, close and open again after
!	return from CALLMIC.
!
! A small user example:
!
! BEGIN
!     EXTERNAL PROCEDURE run;
!     EXTERNAL BOOLEAN PROCEDURE scratchfile,tmpout;
!     EXTERNAL INTEGER PROCEDURE save,callmic;
!     EXTERNAL TEXT PROCEDURE inline,conc,tmpnam;
!     INTEGER rc;
!     TEXT micfile,savfile;
! 
!     micfile:- inline("Mic file name:",Sysin);
!     IF micfile == NOTEXT THEN micfile:- Copy("Mic.tmp");
!     savfile:- inline("Sav file:",Sysin);
! 
!     Outtext("End with extra CR");
!     Outimage;
!     INSPECT NEW Outfile(micfile) DO
!     BEGIN
! 	Open(Sysin.Image);
! 	! Note the nice way of copying input lines
! 	! from Sysin to MICFILE.;
! 	WHILE inline("Command:",Sysin).Strip =/= NOTEXT DO
! 	Outimage;
! 	Close
!     END micfile creation;
! 
!     rc:= callmic(micfile,savfile);
!     Outtext("Return code:");
!     Outint(rc,5);
!   Outimage;
! 
! END of program
;
OPTIONS(/E/C/-Q/-A/-I/-D);
EXTERNAL BOOLEAN PROCEDURE scratchfile,tmpout;
EXTERNAL PROCEDURE run;
EXTERNAL INTEGER PROCEDURE save;
EXTERNAL TEXT PROCEDURE conc,tmpnam;
INTEGER PROCEDURE callmic(micfile,savfile);
VALUE micfile,savfile;   TEXT micfile,savfile;
IF micfile =/= NOTEXT THEN
BEGIN
    INTEGER returncode;   TEXT cmdfile;

    tmpout("MIC",conc("/",micfile));

    IF savfile =/= NOTEXT THEN
    BEGIN
	INSPECT NEW Outfile(conc(micfile,"/ACCESS:APPEND")) DO
	BEGIN   Open(Blanks(40));
	    Outtext(".REVIVE .RUN ");   Outtext(savfile);   Close
	END add sav file name;
	returncode:= save(savfile,TRUE);
	IF returncode = 0 THEN
	run("SYS:MIC",2) ELSE
	IF returncode < 0 THEN
	BEGIN   Outtext("? Save failed with filename:");
	    Outtext(savfile);   Outimage
	END ELSE
	scratchfile(savfile);
    END savfile =/= notext ELSE run("SYS:MIC",2);
    scratchfile(micfile);
    scratchfile(tmpnam("MIC"));
    scratchfile(cmdfile);
    callmic:= returncode;
END of callmic;