CompuServe Thread

Forum unknown · Programming

#Modula Problem

3 messages in this thread
#23270From: John MesiavechJun 17, 1986 6:00 PM
hi! Am writing a program in Modula-2 and am getting an annoying problem, which is this: In the program, i have a procedure called OpenLibraries, defined as such: PROCEDURE OpenLibraries () : BOOLEAN' (* oops, replace above with semicolon*) IntuitionBase:= OpenLibrary (IntuitionName,0); IF IntuitionBase = 0 THEN RETURN FALSE END; GraphicsBase:=OpenLibrary (GraphicsName,0); IF GraphicsBase = 0 THEN RETURN FALSE END; RETURN TRUE; END OpenLibraries; In addition, have a variable in the VAR section defined as: VAR Dummy : BOOLEAN; Now, in the main program, when I do this: Dummy:=OpenLibraries; I keep getting a type mismatch error. Now, as the procedure returns a Boolean and the variable IS Boolean, what's going on? This is the ONLY error in the entire program, and is quite frustrating! Any help would be appreciated…Please reply in EasyPlex, since am going on a trip and won't be back in a while…Thanks!
#23307From: Richard BielakJun 17, 1986 9:47 PM
Hi John! There is a very easy way to fix your problem. The line in your main program should be: "Dummy := OpenLibraries();". If this looks strange, remember that in Modula-2 you can procedure variables. Your original statement tries to assign a procedure to a BOOLEAN variable which results in a type mismatch. Putting the "()" indicates that the procedure must be called, and whatever it returns should be assigned to "Dummy". This is a little weird, since not to many languages have procedure variables. (In C there are pointers to functions which are basicaly the same thing….) …….hope this helps……Richie
#23307From: Richard BielakJun 17, 1986 9:47 PM
Hi John! There is a very easy way to fix your problem. The line in your main program should be: "Dummy := OpenLibraries();". If this looks strange, remember that in Modula-2 you can procedure variables. Your original statement tries to assign a procedure to a BOOLEAN variable which results in a type mismatch. Putting the "()" indicates that the procedure must be called, and whatever it returns should be assigned to "Dummy". This is a little weird, since not to many languages have procedure variables. (In C there are pointers to functions which are basicaly the same thing….) …….hope this helps……Richie