Page 1 of 1

#define with parameters

Posted: 31 December 2008, 13:05 PM
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

Re: #define with parameters

Posted: 31 December 2008, 13:21 PM
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 

Posted: 01 January 2009, 13:21 PM
by ndudman
Thanks, thats what I thought... and what I did, just wanted to check :)

Thanks