#define with parameters

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

#define with parameters

Post by ndudman »

Is there another way in Zbasic to do the following ? I.e compiler directive to change a function name to something more more_readable. I might have the syntax wrong also ?

Code: Select all

#define more_readblei(sfr, bit) (ibs(sfr, bit))

function ibs(byval a as byte, byval b as byte) as byte
	ibs = a + b
end function

Sub Main()
	Debug.print more_readble(2,4)
End Sub
Thanks
Neil
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: #define with parameters

Post by dkinzer »

ndudman wrote:Is there another way in Zbasic to do the following ?
The short answer is that ZBasic doesn't have a text substitution macro facility like the C preprocessor does.

For the particular example you cited, it would seem that the code below would achieve the same result.

Code: Select all

Function more_readable(ByVal a as Byte, ByVal b as Byte) as Byte
   more_readable = a + b
End Function 
- Don Kinzer
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

Thanks, thats what I thought... and what I did, just wanted to check :)

Thanks
Post Reply