en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en en en en en en en en en en en de nds en en en en nl en en en en en en en en en en en en en en en nl en en en en en en en en en en en nl en en en en en en en en en en en fr en da en en nds en en en en nl en en en en en en en en en en en en en en nl en en en en en en en en en fr en da en en nds en en en en nl vi en en en en en en en en en en en en en en nl en en en en en en en en fr en da en en nds en en en en nl fr en en en en en en en en en en nl en en en en en en en en fr en da en en nds en en en en nl en en en en en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in Programming only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
I'm posting this here assuming that macro expansion is common to PBWin & PBCC. Any problems - sue me.
Just out of curiosity I tried this macro which fails because parameter substitution does not occur:
'------------------------------------------------------------------ ' Are macros expanded before or after .inc files are included? #IF NOT %DEF(%WM_COMMAND) %WM_COMMAND=&H111 #ENDIF MACRO mjump(a,b)=IF (lControlId=%a) AND (lmsg=%b) THEN GOSUB a_b '------------------------------------------------------------------
I'm expecting it to expand mjump(IDC_BN1,WM_COMMAND) to:
IF (lControlId=%IDC_BN1) AND (lmsg=%WM_COMMAND) THEN GOSUB IDC_BN1_WM_COMMAND
Clearly I'm missing something!
Join Date: Sep 2000
15 Jan 2008, 06:00 PM
PB is translating %A and %B literally, so it expects to have those constants defined. The working code should look like this:
MACRO mjump(a,b)=IF (lControlId=a) AND (lmsg=b) THEN GOSUB a_b [..] mjump(%IDOK,%WM_COMMAND)
...that way you can also use variable names (or numeric values) for the mjump() parameters.
I don't think partial name uses are permitted with MACROs.
kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me
Join Date: Aug 2005
15 Jan 2008, 06:12 PM
I see. So it's evaluation followed by text substitution.
In this case, I want to use the % in the condition but not in the label. Can't see a way around it.
Join Date: Aug 1998
16 Jan 2008, 08:04 AM
MACROs are not "evaluated" at all; they are simple text substitution at compile time.
If the resulting text is compilable it compiles; otherwise it returns an error.
>I don't think partial name uses are permitted with MACROs
CC3/Win7: ARRAY SORT UDT array on member name September 04, 2002
....because this uses text substitution to complete partial variable names.
Port Washington WI USA
Join Date: Sep 2000
16 Jan 2008, 11:46 AM
I read your code. That's member names not variable names, which is what I was talking about. AFAIK, it's simply not possible to concatenate one or more MACRO substitutions to reference an actual variable. If you have code to do this, please show it.
#Compile Exe Macro VAR_ASSIGN(var, num, value) var_num = value End Macro Function PBMain Local var_1 As Long Local var_2 As Long Local var_3 As Long VAR_ASSIGN(var, num, 10) End Function
kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me
Join Date: Aug 1998
16 Jan 2008, 12:16 PM
My sort example creates the 'actual' variable name from the UDT variable name plus "." plus the member name.
Your demo code .. passing "var" and "num" as arguments one and . should be producing "var_num = 10" which is a perfectly valid statement. But somehow I don't think it's what you wanted.
One thing you have to watch out for when concatenating .. spaces are significant. I remember dinking around a lot with the spaces to get that to work correctly.
I'll take a pass on commenting about the utility of using a MACRO to make a simple assignment like this; but I'm sure this example is not a complete statement of the challenge since it would be totally silly to bother with a MACRO for a simple assignment statement.
Port Washington WI USA
Join Date: Sep 2000
16 Jan 2008, 12:26 PM
Yes, it would be handy for many uses to cut down code size. That was just a snippet but you get the general idea.
Another thing I toyed with (this time with success) was to get functions EXPORTed depending on a flag and without having to make the declaraton twice in an #IF / #ENDIF block.
This is one demonstration which shows the usefulness of MACRO text substitution:
#If %Def(%EXPORTED) Macro FUNC_MODE(r) = Export As r #Else Macro FUNC_MODE(r) = As r #EndIf FUNCTION Abc FUNC_MODE(LONG) END FUNCTION
kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me
Join Date: Aug 1998
17 Jan 2008, 07:43 AM
Not directly on macro, but for the Export/No Export thing, I do that depending if I am compiling to an EXE or DLL, and the compiler supplies the equate...
#IF %PB_EXE FUNCTION TSEDI_MakeIEASegment(XC AS INTERCHANGETYPE) AS STRING #ELSE FUNCTION TSEDI_MakeIEASegment ALIAS "TSEDI_MakeIEASegment" (XC AS INTERCHANGETYPE) EXPORT AS STRING #ENDIF
Port Washington WI USA
Join Date: Sep 2000
17 Jan 2008, 12:14 PM
The downside to that approach is that you need two declarations for each function as I mentioned. Also, I use the equate method in case you want to use a certain function in a DLL but not export it. The exports are defined per-#include file using an equate for each.
kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me
Join Date: Aug 1998
17 Jan 2008, 12:43 PM
Also, I use the equate method in case you want to use a certain function in a DLL but not export it. The exports are defined per-#include file using an equate for each.
Whoa, that's way too complex for a kid from the South Side of Milwaukee. This kid, anyway.
Easier to just type it twice, ainna?
Port Washington WI USA
Join Date: Sep 2000
17 Jan 2008, 01:03 PM
Different strokes for Wisconsin folks, I guess!
kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 09:34 PM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.