Preprocessor directive

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
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Preprocessor directive

Post by spamiam »

I want to use Option.TargetDevice in a preprocessor directive.

e.g. #If (Left(Option.TargetDevice,4) = "ZX24")

Since the pin assignments (like the LEDs) are the same within the ZX24 family, I do not need to know if it is an -A, -AE, -N, etc. (at least I think all the pin assignments are the same withing the family)

I get successful compilation if I do not use the Left() function and just check the entire Option.TargetDevice string, but I want to simplify by using the Left() function. Is there some way to extract the first 4 characters in the preprocessor directive?

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Preprocessor directive

Post by dkinzer »

spamiam wrote:Is there some way to extract the first 4 characters in the preprocessor directive?
Not directly. As you've discovered, ZBasic System Library functions currently can't be used in the conditional expressions. A "trick" that might serve your purposes is:

Code: Select all

#if &#40;Option.TargetDevice >= "ZX24"&#41; And &#40;Option.TargetDevice < "ZX25"&#41;
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

I had considered that trick, but I thought it might be excessively simple, but since the number of strings that the Option.TargetDevice is going to return is quite limited and predictable, I think this trick will work!

-Tony
Post Reply