Silverfrost Forums

Welcome to our forums

Problem with ADD_MENU_ITEM@

21 Apr 2020 8:35 #25265

Using FTN95 8.62.1 I received the following error message:

           CALL ADD_MENU_ITEM@ (iDynMenuHandle, cLastProjects(I), 1, 0, CB_OldProject)
*** Error 1244: The third argument of ADD_MENU_ITEM@ is passed as a reference that should not be a constant nor an expression
*** Error 1244: The fourth argument of ADD_MENU_ITEM@ is passed as a reference that should not be a constant nor an expression

after changing the constants 0 and 1 to iZero and iOne, the software is not working anymore correct. First setting of the older projects into menu works fine. I can select a project. After selection I remove and then update the list of projects. But then it gets funny: sometimes the projects have a checkbox in front; sometimes they are greyed; and sometimes both. This did never happen before.

21 Apr 2020 9:04 #25266

I suspect that there is something else causing this failure.

These error reports can be fixed by:

  1. replacing 0 by iZero which has been given the value 0 etc. or
  2. suppressing error 1244.

If you use method (2) then it may reveal that something else is causing the failure. If not then I think that I would need a demo program to look at.

21 Apr 2020 12:50 #25267

It's definitely a bug in ADD_MENU_ITEM@. Changing back to calls with constants and using OPTIONS (ignore 1244), the program is running again perfectly.

OPTIONS (ignore 1244)

    SUBROUTINE UpdateProjectList (cDir, iAction) 
    USE      bbmanData
    IMPLICIT NONE
    INCLUDE  <clearwin.ins>
    CHARACTER    cDir*(*)         ! Directory name
    INTEGER      iAction          ! Action key:   -1=remove;   +1=add
    INTEGER      I, J  !--- , iZero, iOne
    INTEGER, EXTERNAL :: CB_OldProject, CB_EXIT

    DO I= 1, iNrOfLastProj+2
       CALL REMOVE_MENU_ITEM@ (iDynMenuHandle)
    ENDDO

    SELECT CASE (iAction)
       CASE (-1)                  ! Eliminate cDir from list
       
          DO I= 1, iNrOfLastProj
             IF (cDir .EQ. cLastProjects(I)) cLastProjects(I) = ' '
          ENDDO
          J = 1
          DO I= 1, iNrOfLastProj
             cLastProjects(J) = cLastProjects(I)
             IF (cLastProjects(I) .NE. ' ') J = J + 1
          ENDDO
          iNrOfLastProj = J - 1

       CASE (+1)                  ! Shift project names down and add new project on top

          DO I= 9, 2, -1
             cLastProjects(I) = cLastProjects(I-1)
          ENDDO
          J = INDEX (cDir, char(0))
          IF (J .GT. 0 ) cDir(J:) = ' '
          cLastProjects(1) = cDir
          IF (iNrOfLastProj .LT. 9)  iNrOfLastProj = iNrOfLastProj +1

    END SELECT

!-- iZero = 0
!-- iOne  = 1
    DO I= 1, iNrOfLastProj
       IF (cLastProjects(I) .NE. ' ') THEN
!--       CALL ADD_MENU_ITEM@ (iDynMenuHandle, cLastProjects(I), iOne, iZero, CB_OldProject)
          CALL ADD_MENU_ITEM@ (iDynMenuHandle, cLastProjects(I), 1, 0, CB_OldProject)
       ENDIF
    ENDDO
    IF (iNrOfLastProj .GT. 0)  CALL ADD_MENU_ITEM@ (iDynMenuHandle, CHAR(0), 0, 0, CB_EXIT)
                               CALL ADD_MENU_ITEM@ (iDynMenuHandle, 'Save and E&xit', 1, 0, CB_EXIT)
!-- IF (iNrOfLastProj .GT. 0)  CALL ADD_MENU_ITEM@ (iDynMenuHandle, CHAR(0), iZero, iZero, CB_EXIT)
!--                            CALL ADD_MENU_ITEM@ (iDynMenuHandle, 'Save and E&xit', iOne, iZero, CB_EXIT)
    RETURN
    END SUBROUTINE UpdateProjectList

The Program is very large and complex. I don't think that I can make a small example to demonstrate the problem.

21 Apr 2020 2:57 #25268

I have found another way to get around this problem.

There is an old alternative to ADD_MENU_ITEM@ which has the same name but without the @. The alternative allows literal 0 and 1 for these arguments.

Like ADD_MENU_ITEM@ it is declared in clearwin.ins.

p.s. Another thought: iZero and iOne probably need to be global (e.g. SAVEd) and not local.

Please login to reply.