using AND as an IF statement
With the picbasic IF statement being limited to a simple GOTO function, it seems to me that I remember ever being creative with in an AND statement to manipulate variables.
i.e.
B0 = 5 AND B1 = 10
In english, this translates to: If B1 = 10 then load B0 with a 5
has anyone done this or anything similar??
Tnx,
dw
continued: Using AND as an IF statement
Hi Paul,
And thanks for your post.
I am the originator of the post, and yours has been the closest to responding to its original meaning. Although, I have been entertained by the various responses. :) Thats part the fun.
Its fun to watch a topic start and monitor its wild swings.
I got the original PBC years ago when it first came out, and yes, I was extremely happy with it. I knew, from many programming languages previous, that the IF test statement was missing, and without it, have created many real fun projects. My latest (last winter) was an automated antenna tuner run by just one pic. It constantly monitors the frequency band of my transmitter, and pre-sets up the tuner which is located about 30 feet outside, for a low SWR on 9 different bands.
Part of the fun for me, is being able to create something for under $50 which would haved cost me close to $400 off the shelf.
I pondered whether to simply purchase PBP for this latest project.
The weird thing is, I could sware that I figured out a way to make a semi- IF statement work using the AND in PBC on one of my very first projects.
I have scratched through all of my old projects paperwork finding nothing.
I figured, with all of the top notch programmers on this BB, that someone would have been doing something similar. Perhaps even a pre-built assembly subroutine that would simulate an IF statement.
I guess not.
But let the fun continue!!
Thanks dude,
dw_pic :)
Quote:
Originally Posted by paul borgmeier
It's not actually crippled, it is just not developed. MELabs put less work into it, they charge less for it. As you noted, it is much closer to ASM than it is to BASIC.
Much like ErnieM's #2 and I am sure others, here is what I did in the past. It is not quite as clean as the PBP version but is quite readable nonetheless (one extra goto per if-then)
;in PBP
If X = 5 then
x = 5
y = 6
z = 7
Else
x = 7
y = 0
z = 6
Endif
;in PBC
If X<>5 then Else1
x=5
y=6
z=7
goto EndIf1
Else1:
x=7
y=0
z=6
EndIf1:
for the next If-Then, use Else2, Endif2, etc.
Paul Borgmeier
Salt Lake City, Utah
USA