line feed
jcleaver
Posts: 17
·simple question· when you know the answer
when you have a long program line and you want it to display better
how do you insert a line feed for display without the program thinking is a new line
seee no caps got my keyboard unstuck
when you have a long program line and you want it to display better
how do you insert a line feed for display without the program thinking is a new line
seee no caps got my keyboard unstuck
Comments
· LOOKUP idx, [noparse][[/noparse]%000, %001, %010,······· ' this line is split
···············%011, %100, %101]
Note that the trailing comma; that said, the editor is smart enough to let you have a comment on a split line.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
main:
IF wiper1>5120-2*delta AND wiper1< 4920 AND wiper2 < 2* delta AND wiper2 >200 THEN delta = (9*delta +(wiper2+5120-wiper1)/2)/10· ELSEIF wiper2>5120-2* delta AND wiper2<4920 AND wiper1 <2 * delta AND wiper1> 200 THEN delta = (9*delta +(wiper1+5120-wiper2)/2)/10· END IF
does not work unless continuious line also endif gives syntax error no matter where it is
Also, if you break your formulas/equations up into variables (so instead of something like delta = (9*delta +(wiper2+5120-wiper1)/2)/10 you could first define a variable called result to equal that equation, then make delta = result. Though ofcourse you'd be trading off RAM for cleanliness.
Im an experienced programmer with another version of BASIC (DarkBASIC Pro) but Im only just getting into using Stamp's version, so Im not sure if Stamp's version allows for functions yet, though Id imagine if it did then placing those formulas in functions would not only clean it up but also reduce the amount of code required since the formula is only written once.
<EDIT>
Like I said Im not too experienced with Stamp yet and I dont have the compiler/your source code on this computer but here's my attempt at shortening it up (without the use of functions as Im not sure if they're available).
Might want to make some of those variables constants but that looks neater alreadt [noparse];)[/noparse]
Hope it helps,
- Adam
Post Edited (AdamE) : 4/25/2006 10:49:09 PM GMT
delta = (9*delta +(wiper2+5120-wiper1)/2)/10
ELSEIF wiper2>5120-2* delta AND wiper2<4920 AND wiper1 <2 * delta AND wiper1> 200 THEN
delta = (9*delta +(wiper1+5120-wiper2)/2)/10
ENDIF ' <-- no space in ENDIF
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
· IF wiper1 > 5120 - 2 * delta
evaluates as:
· IF wiper1 > 5118 * delta
IF that's not what you mean then you will need to use parenthesis:
· IF wiper1 > 5120 - (2 * delta)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
· IF wiper1 > 5120 - (2 * delta) THEN
··· IF wiper1 < 4920 THEN
····· IF wiper2 < 2 * delta THEN
··· ··· IF wiper2 > 200 THEN
····· ··· delta = (9 * delta + (wiper2 + 5120 - wiper1) / 2) / 10
· ····· ELSE
··· ····· IF wiper2 > 5120 - (2 * delta) THEN
····· ····· IF wiper2 < 4920 THEN
······· ····· IF wiper1 < 2 * delta THEN
········· ····· IF wiper1 > 200 THEN
··········· ····· delta = (9 * delta + (wiper1 + 5120 - wiper2) / 2) / 10
· ············· ENDIF
··· ········· ENDIF
····· ····· ENDIF
······· · ENDIF
····· · ENDIF
···· ·ENDIF
··· ENDIF
· ENDIF
The separates every term and allows you to spot errors more easily.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
tracy and jon's programs worked perfectly
i do appreicate all your help
have a nice day