Shop OBEX P1 Docs P2 Docs Learn Events
Spin question — Parallax Forums

Spin question

RichardFRichardF Posts: 168
edited 2007-07-04 23:12 in Propeller 1
Anyway to do this:

···· if acknowledge
······· 'do this

Where acknowledge is the result of reading·status of ina[noparse][[/noparse]pin].
or:
···· repeat until done
······· 'do something else

Where done is the result of reading status of ina[noparse][[/noparse]pin].

I guess this would be like a macro and would make for easier to understand code.

Thanks,
Richard·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-04 16:21
    You can just do "if ina[noparse][[/noparse]pin]" or "if ina[noparse][[/noparse]pin] == 1".

    You can also declare a variable "acknowledge", do "acknowledge := ina[noparse][[/noparse]pin] == 1", then do "if acknowledge".

    The case with the repeat is a little more difficult. If "done" is a complex condition, you could declare it as a method like:
    pri done
       done := ina[noparse][[/noparse]pin] == 1
    
    



    You could then do your "repeat until done".
  • RichardFRichardF Posts: 168
    edited 2007-07-04 23:12
    Thanks for the ideas Mike. My question came up because of a repeat that has to execute as fast as possible, so I don't want to call a subroutine. I will just stick with:

    repeat
    if ina[noparse][[/noparse]pin] 'acknowledge
    'do ......
    or
    if not ina[noparse][[/noparse]pin] 'not ready
    'do ...

    Thanks,
    richard
Sign In or Register to comment.