Cheapy Shortcut?


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511

    Default Cheapy Shortcut?

    Hello Folks,

    Is there a way to assign values to a variable so that one word will suffice for the code?

    for example:

    Define LedOn GPIO.1=1
    Define LedOff GPIO.1=0
    Define PressButton GPIO.2=1;
    Define ReleaseButton GPIO.2=0;

    Loop:
    LedOn Here it turns light on
    Pause 1000
    LedOff Here it turns light off

    *****another example......
    PressButton
    .......
    ReleaseButton

    *******another example

    if PressButton then
    ....
    ...
    endif

    goto Loop

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    There's a way to do the LED part (sort of), but I don't think the PressButton example can be done.

    Place these macros at the beginning of the program.
    Code:
    @LedOn  macro
      GPIO.1=1
    @ endm
    
    @LedOff  macro
      GPIO.1=0
    @ endm
    Then to use them:
    Code:
    Loop:
    @ LedOn    ' Here it turns light on
      Pause 1000
    @ LedOff   ' Here it turns light off
      Pause 1000
    goto Loop
    Not exactly what you were looking for, but it's close.

    Best regards,
      Darrel

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts