Ok.. im doing some funky stuff with macro's again, and have hit a brick wall on this last idea.

As background, im beginning some revisions into the OOP.inc file. Thomas had suggested some good ideas to thin out the amount of heap space used to get the same job done.

One of the solutions is to make a type equate for each method, and use the value stored later in the equate when calling a method function.

ie)

&ClassName&_&MethodName&Typ equ 1 ; Virtual
&ClassName&_&MethodName&Typ equ 0 ; Non Virtual

etc.

I have this done and working already. Every method of every class gets one unique equate describing its 'type'. And the equate name itself is built from the class and method name info, as shown above (actually done with CATSTR).


My problem is using this info. I can get the pieces in text equated strings, and use CATSTR to build the name again when calling the function, but what i can not seem to do for the life of me is this:
  sz0 CATSTR Class, <_>,Meth,<Typ>

%echo sz0
IFDEF sz0
%echo ITS DEFINED!
ELSE
%echo ITS NOT DEFINED!!!!!
ENDIF

Problem is, if i can get it to compile, it recognizes the sz0 as being defined, not the text content it represents (" Class_NameTyp ")

If there is a macro GURU out there who thinks they can solve this im eager to see the solution :grin: . As well, i would eventually need to also perform a simular IF sz0 eq 0 to filter out Virtual methods from non virtual. But at this point, i can even see if it exists :(

Thanx for your help..
:alright:
NaN
Posted on 2002-04-14 00:04:08 by NaN
Hmmm

I found a work around.. but its not elagent.. I still havent figured out the above problem, but i can avoid it by nesting macro calls (call another macro from wihtin a first macro ~ somehow, passing the strings as params cleans them up for evaluations better???? )


But i still would like to hear a better solution if someone has it.

:alright:
NaN
Posted on 2002-04-14 00:24:56 by NaN
This is more to the problem at hand:

Can anyone explain to me why this will work:


SomeMacro MACRO TextIn:REQ

IF @InStr(1, <TextIn>, <AWord>)

%echo Found Aword in the string

ENDIF
ENDM


ANd not this:

SomeMacro MACRO TextIn:REQ

LOCAL subst

subst CATSTR <TextIn>, 1, 10

IF @InStr(1, subst, <AWord>)

%echo Found Aword in the string

ENDIF
ENDM


Where i pass in a line like "AwordIsHereInTheString" ???

I know all these probs are related somehow, but i cant figure it out...

:alright:
NaN
Posted on 2002-04-14 01:19:20 by NaN
This should work, i think.



SomeMacro MACRO TextIn:REQ
LOCAL subst

subst [B][COLOR=red]SUBSTR[/COLOR][/B] <TextIn>, 1, 10

IF @InStr(1, [B][COLOR=red]%[/COLOR][/B]subst, <AWord> )

%echo Found Aword in the string

ENDIF
ENDM
Posted on 2002-04-14 03:55:26 by Four-F
Nan,

Maybe something like this will work? (Sorry I didn't try it)



SomeMacro MACRO TextIn:REQ
LOCAL subst

subst CATSTR <TextIn>, 1, 10

IF @InStr(1, &subst&, <AWord> )

%echo Found Aword in the string

ENDIF
ENDM


Here I used the substitution operartor & to expand the variable substr into it's value, I think that's what you need.

Sorry I don't have time to code and try it, I have to get back to painting the kitchen :-)
Posted on 2002-04-14 09:34:36 by Ernie
Thanx Four-F That worked! I tried a simular approach but it failed. I placed the % at the begining of the line before the 'IF', this wont work.

PS: My typo with the CATSRT i meant SUBSTR

Ernie, you method wont work, i tried it earlier. (tired alot before posted), but thanx anyways!

Anyone have a solution to the IFDEF delema (the first post)??

Thanx again both of youf or your suggestions.
:alright:
NaN
Posted on 2002-04-14 15:29:05 by NaN
Sorry for my ugly english.
But if i understood you correctly, you want to do something like this.




.386
.model flat, stdcall
option casemap:none

; Method definition
Class1_Method1Typ equ 1 ; Virtual
Class1_Method2Typ equ 0 ; Non Virtual

IsClassMethodDefined MACRO Class:REQ, Meth:REQ
local sz0, val

; %echo Class
; %echo Meth

sz0 CATSTR <Class>, <_>, <Meth>, <Typ>

; %echo sz0

% IFDEF sz0
val TEXTEQU %sz0

; %echo val

IF val EQ 1
%echo *** sz0 DEFINED AS VIRTUAL ***
ELSEIF val EQ 0
%echo *** sz0 DEFINED AS NON VIRTUAL ***
ENDIF
ELSE
%echo *** sz0 NOT DEFINED! ***
ENDIF

ENDM


.code
start:

echo
IsClassMethodDefined <Class1>, <Method1>
echo
IsClassMethodDefined <Class1>, <Method2>
echo
IsClassMethodDefined <Class2>, <Method1>
echo

ret
end start



Compiling this piece of code echoes:





*** Class1_Method1Typ DEFINED AS VIRTUAL ***

*** Class1_Method2Typ DEFINED AS NON VIRTUAL ***

*** Class2_Method1Typ NOT DEFINED! ***



Hope this is what you are looked for.
If not, please, explain it more detail.
Posted on 2002-04-14 19:48:08 by Four-F
This is EXACTLY what im looking for! Thanx alot! This was my first attempt (in structure) but i couldnt get it to work.. so i made a work around.. But this is much more straight forward (as i wanted)

Thank you very much Four-F!!
:alriight:
NaN
Posted on 2002-04-14 20:11:03 by NaN
NaN, the key is the % at the begining of the line which forces the evaluation of the text the sz0 represents, and the value represented by that text.
[b]%[/b] IFDEF sz0
Posted on 2002-04-15 10:27:46 by bitRAKE
Thanx bitRAKE, i thought i tried that, but perhaps i didnt try it exactly... (i was also playing with @StrCat() as well on the same IF line, could have tested and failed under this condition, and not the above 2 line solution).

Thanx again!
:alright:
NaN
Posted on 2002-04-15 10:46:14 by NaN
@StrCat..I don't use it no where. I do my own. I dug it out from M32.lib in all kind of ways.

Just a thought
Posted on 2002-04-15 17:48:12 by cmax