Programming > Problems & Solutions
Macro parameter issue
Brian Alvarez:
I am implementing some DDT statements, this in particular:
--- Code: ---ARRAY SCAN INCLIBS(0) FOR (Comp.CurSystInc+1), = LibName, TO Index
--- End code ---
When converted, PluriBASIC generates a macro called ?ArrayScanString and it is invoked like this:
--- Code: ---?ArrayScanString(-16, inclibs, 0, (EXE.lng(@comp, 6393) + 1), null, null, null, null, =, libname, index, Err)
--- End code ---
I believe the syntax is correct, but at compilation Oxygen complains about this:
--- Code: ---ERROR: ERROR: Undefined Symbol: @
WORD: 0
IN: add_systinc
LINE: 14902
FILE: "main source
--- End code ---
There are no @ symbols inside the macro, so, i am guessing the parameter (EXE.lng(@comp, 6393) + 1) is not being interpreted correctly.
When removing the brackets, so that it gets genrated like this:
--- Code: ---?ArrayScanString(-16, inclibs, 0, EXE.lng(@comp, 6393) + 1, null, null, null, null, =, libname, index, Err)
--- End code ---
Oxygen says:
--- Code: ---ERROR: ERROR: not defined
WORD: ?iend
IN: add_systinc
LINE: 14902
FILE: "main source
--- End code ---
I suppose it refers to either of these lines inside the macro:
--- Code: ---...
int ?iEnd = 0
if istart = null then
?iStrt = a.lbound(1)
else
?iStrt = istart
end if
if ifor = null then
?iEnd = a.ubound(1)
else
?iEnd = ?iStrt + ifor
end if
For ?index1 = ?iStrt to ?iEnd
For ?index2 = ?iStrt to ?iEnd
...
--- End code ---
Is the parameter being interpreted wrong?
Brian Alvarez:
In this marco invocation:
--- Code: ---?ArrayScanString(-16, rk, cns.c(listid), cne.c(listid), null, null, null, null, =, param, index, Err)
--- End code ---
cns and cne are a class instances and c is a method in those class instances. listid is a parameter passed to the c method in the cne and cns classes, but Oxygen complains about this:
--- Code: ---ERROR: ERROR: cannot use variable as constant
WORD: listid
IN: getdatatypeidbyname
LINE: 11051
FILE: "main source
--- End code ---
Note that listid is not individually used inside the macro. I think it is not understanding that the macro parameter is composed of a class instance with a method and it's parameter. How can i fix this?
Brian Alvarez:
I believe the problem is that Oxygen works fine with this code:
--- Code: ---#if typecodeof(null) = 0 ' Works fine.
--- End code ---
But is complaining at this exapanded code:
--- Code: ---#if typecodeof((EXE.lng(@comp, 6393) + 1)) = 0 ' Compile error.
--- End code ---
--- Code: ---#if not match(((EXE.lng(@comp, 6393) + 1)), (null)) ' Compile error.
--- End code ---
--- Code: ---#if not match((cne.c(listid)), (null)) ' Compile error.
--- End code ---
Basically what i need is to know if one of the passed parameters is a literal null and not a literal 0 or a variable with a value of 0.
JRS:
Have you thought of using hex notation for your zero constants?
Brian Alvarez:
--- Quote from: John on February 13, 2021, 06:18:59 AM ---Have you thought of using hex notation for your zero constants?
--- End quote ---
What do you mean?
Navigation
[0] Message Index
[#] Next page
Go to full version