| Author |
Message |
spamiam
Joined: 13 Nov 2005
|
|
Posted: 23 August 2008, 22:11 PM Post subject: Preprocessor directive |
|
|
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 |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 23 August 2008, 23:25 PM Post subject: Re: Preprocessor directive |
|
|
| 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: | | #if (Option.TargetDevice >= "ZX24") And (Option.TargetDevice < "ZX25") |
|
|
| Back to top |
|
 |
spamiam
Joined: 13 Nov 2005
|
|
Posted: 24 August 2008, 1:24 AM Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|