Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
16 Views

Elegant abnormal termination exit for QuickWin app

I am having some trouble handling an abnormal termination with an application using QuickWin graphics.  Here is a code snippet with an idea of what I am trying to do.

ICOLOR = SETBKCOLORRGB(ICTXTBACK)
ICOLOR = SETTEXTCOLORRGB(ICTEXT)
CALL SETVIEWPORT(0_2, 0_2, X_WIDTH, Y_HEIGHT)
CALL CLEARSCREEN($GVIEWPORT)
CALL SETTEXTWINDOW(0_2, 0_2, MAXIMUM_ROWS, MAXIMUM_COLS)
STATUS = WRAPON($GWRAPON)
!-------------------------------PREPARED BACKGROUND AND BORDERS
CALL BACKSPACE_DEBUG()
DO J = 1, IECOUNT
    READ(UNIT = FILDBGNUM, FMT = CFORM) FILNAME
    IPOS = SCAN(FILNAME, '.', BACK = .TRUE.)
    IBEG = IPOS - 114
    IF (IBEG < 1) IBEG = 1
    IEND = IPOS
    CALL SETTEXTPOSITION(INT(3 * J - 2, 2), 1_2, RC)
    CALL OUTTEXT('Run...' // FILNAME(IBEG:IEND))
    CALL SETTEXTPOSITION(INT(3 * J - 1, 2), 1_2, RC)
    CALL OUTTEXT('THE RUN HAS TERMINATED ABNORMALLY')
    CALL SETTEXTPOSITION(INT(3 * J - 0, 2), 1_2, RC)
    CALL OUTTEXT('PLEASE CHECK')
END DO
!------------------------------SET THE EXIT MODE
FINISH = SETEXITQQ(QWIN$EXITPERSIST)

When I run this code, the window persists as it should but the window is empty with no text at all.  When stepping this code through the debugger, the first OUTTEXT call goes into some assembly code which apparently is catching some sort of error.

Any help here would be greatly appreciated.

0 Kudos
9 Replies
Highlighted
16 Views

0 Kudos
Highlighted
Valued Contributor III
16 Views

When stepping this code through the debugger, the first OUTTEXT call goes into some assembly code 

 

Well it would given you don't have the debug source code for OUTTEXT which is an intel Qwin routine. If there is an error you might want to add a call to getlasterror() before and after the outtext to see if any error message has been set thought I note the help entry does not explicity state that error codes are set this way.... 

0 Kudos
Highlighted
16 Views

Well, it turns out that the problem lies in the first two lines.  I am wanting to preserve a portion of the original screen color to use for this "abort" window.  Unfortunately, I have not done this.  The two color entries are getting set to zero and this is causing the "writing" to disappear into the background.

The original code which did this maintained the colors in a COMMON block (remember those?).  Unfortunately, this means of maintenance is apparently not allowed when I use my own INITIALSETTINGS routine.  I am having a little trouble maintaining these color settings.

0 Kudos
Highlighted
Valued Contributor III
16 Views

Stick all your logical colours in a module, initialise and then USE wherever needed. It is for most purposes the same deal as a COMMON.

0 Kudos
Highlighted
16 Views

I have a module which does most of my graphics (line drawing, text rendering, etc.).  Inside this module is a routine which initially sets all the colors for the graphics based on user input.

The abnormal termination routine which has the code snippet lies outside this graphics module, as does the LOGICAL FUNCTION INITIALSETTINGS.  I am uncertain as to why these routines lie outside, but I have discovered that if I put the abnormal termination routine inside the module, it will not compile with error #7001.  The module itself maintains the colors as PRIVATE INTEGER variables.  When I write simple Get routines to return these values, the graphics module again will not compile with error #7001.  Also, if I declare these PRIVATE INTEGER variables as PUBLIC and attempt to get them with a USE clause in the abnormal termination routine, the routine will not compile complaining the color variables in question are undefined.  I am flummoxed.

0 Kudos
Highlighted
Valued Contributor III
16 Views

error #7001: Error in creating the compiled module file. - is that the error? I do not know the reasons for that. does the name of your abnormal termination routine cause some name conflict? Tried using a different name to test? What is the full error message you get?

 

0 Kudos
Highlighted
16 Views

Yes, that was the error.  I have a graphics module with all the color variables.  I have now tried the following:

! Within the module
INTEGER (KIND = 4), PRIVATE :: ICTEXT
INTEGER (KIND = 4) FUNCTION GET_ICTEXT()
    GET_ICTEXT = ICTEXT
END FUNCTION GET_ICTEXT

I compile the module without errors.  I then take my abnormal termination routine and add the line

USE GRAPHICS_MODULE, ONLY : GET_ICTEXT

I try to compile this routine.  It complains

error #6580: Name in only-list does not exist.   [GET_ICTEXT]

Huh?  If I do not use the ONLY clause, it still complains

error #6404: This name does not have a type, and must have an explicit type.   [GET_ICTEXT]

What?

A possibility for all this lies in the routine that I call from FUNCTION INITIALSETTINGS.  This FUNCTION has the following statement

USE GRAPHICS_MODULE, ONLY : INITIAL_STUFF

and it is this routine, INITIAL_STUFF, that reads the data from the input file and sets the colors and other graphics limits.  With all this being part (in a sense) of INITIALSETTINGS, perhaps the QuickWin linkage is demanding it be static data or global or ....  I am only guessing.

0 Kudos
Highlighted
Valued Contributor III
16 Views

Do you have a global PRIVATE in GRAPHICS_MODULE? That would give error #6580: Name in only-list does not exist.   [GET_ICTEXT] 

0 Kudos
Highlighted
16 Views

No, there is no global PRIVATE in that module.  There are many variables declared PRIVATE, several TYPEs declared PRIVATE and there is a single declaration

PRIVATE :: Routine1, Routine2, ...

And no, GET_ICTEXT is not part of this declaration.

Many years ago I read the documentation on INITIALSETTINGS and it has some pretty restrictive things to say.  My use of INITIALSETTINGS is an extension of the original code base, but not a large extension.  I just created this routine to set up menu names and content that I thought were meaningful.  The flexibility needed here is that our user base would like some choices as to the layout of the application window.  All these options are sent to the application via text input and the INITIAL_STUFF routine does most of the setting of graphics primitives (colors, styles).

I recognize that none of this makes much sense, and I think it might be worth my while to create a fully functional reproducer based on what I have.  This is going to take a little time.

0 Kudos