Can a line label be aliased to a VAR?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219

    Default Can a line label be aliased to a VAR?

    I'm working on a program using PBP2.47 that would have me repeating sub-routines for multiple input conditions and wondered if it were "allowable" to:
    • Alias a VAR to a line label, or
    • Assign a temporary variable name to a previously defined VAR
    My direction was this:
    Monitor two digital inputs then react upon a change and assign a variable name to the detected input variable.
    Scan two other inputs (switch setting) and assign a temporary variable name to VAR Mode.
    Here's a snipet of the code that shows my intentions but falls short of compiling.
    Code:
    Start:
    ' Turn OFF timer and clear registers     
        T1CON.0 = 0         ' Turn off TMR1
        TMR1H = 0           ' Clear TMR1 high byte counter
        TMR1L = 0           ' Clear TMR1 low byte counter
        T1CON = 48          ' Prescaler set to 1:8, and timer OFF
    
    While (lts = 0) and (rts = 0): wend
        pause 10            ' Debounce time
        gosub time1         ' Start timer and come back   
        if (lts = 0) and (rts = 0) then start  'False switch, go back and wait
        if (lts = 1) and (rts = 1) then start  'Hazard lights ON, go back
    
    ' Check mode select switch position and assign Mode variable
        if (msel2 = 0) and (msel3 = 0) then md = 1
        if (msel2 = 1) and (msel3 = 0) then md = 2
        if (msel2 = 0) and (msel3 = 1) then md = 3
            if md = 1 then
                mode = timed    ' Mode now this label 
            endif
            if md = 2 then
                mode = fixed1   ' Mode now this label
            endif
            if md = 3 then
                mode = fixed2   ' Mode now this label
            endif
    
    ' Check which side activated and assign side variables
        if lts = 1 then sd = 1
        if rts = 1 then sd = 2
            if sd = 1 then
                Side_brake = lrl     ' Side_brake assigned to this VAR
                side = lts           ' Side assigned to this VAR
            endif
            if sd = 2 then
                side_brake = rrl
                side = rts
            endif    
        
    goto start
    This way one sub-routine can be performed using the "inserted" variable names, such as:

    Code:
    i = 0
    HIGH side_brake        ' side_brake previously assigned to certain output
    FOR i = 1 to 3
    PULSOUT side, "x time"   ' side previously assigned to certain output
    GOSUB ChecknSee     ' Monitor inputs during OFF period and return
    NEXT i
    LOW side_brake
    RETURN
    I'm hoping I'm doing something feasible but needed someone's help in case I'm close or to stop me before I spiral out of control with an exercise in futility.

    Thanks in advance...
    Louie

  2. #2
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    The simple answer is no. It looks like you cane rewrite this using "select case", and choose the goto destination accordingly.
    Ron

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    Thank you Ron,
    I'll research the Select/Case usage.
    Sometimes I feel I'm over looking something and get caught up in a paralysis of analysis when trying to be efficient about the whole thing.
    Louie

Similar Threads

  1. RF Modules
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 26th June 2010, 17:42
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. having problems with Hantronix 20x4 lcd
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 22nd December 2005, 12:22
  4. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47
  5. 18F6680 and portd problems.
    By jkbh in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th June 2005, 10:54

Members who have read this thread : 1

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