"Variable already an alias" - is there a way to avoid this?


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    I really do not understand why you may need this.

    At design time, you decide what you will connect on which ports. Then you proceed to writing the program.

    At this stage you have lines that will be defining what your circuit will do, at compile time, and what decisions your code will do at run time. Your electric connection cannot change dynamically!

    It just doesn't make sense, to me at least, why move around a LED or Buzzer, or Button from port to port at run time...

    Ioannis
    Last edited by Ioannis; - 17th June 2020 at 20:54.

  2. #2
    Join Date
    Feb 2013
    Posts
    1,153


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    Simple.

    To make code shorter.

    I've posted an example above. Yes it works but I have 40 subroutines and 40 IF THEN's in it. In case of redefinable port<>variable, it would be reduced 4 times.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    I am sure there are other ways...

    Ioannis

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    you can lead a horse to water but ....

    any pin can be addressed with PORTA.0[offset]
    Warning I'm not a teacher

  5. #5
    Join Date
    Feb 2013
    Posts
    1,153


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    So say

    FOR A=1 to 20
    HIGH PORTA+A
    NEXT

    will work?

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    So say

    FOR A=1 to 20
    HIGH PORTA+A
    NEXT

    will work?
    do you think that looks even close ?


    Code:
    FOR A=0 to 20
      PORTA.0[A]=1
    NEXT
    assuming the 18 [chip dependent] pins in that range are set as digital output


    Warning I'm not a teacher

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    I don't mean to be rude or to offend anyone but do you actually read and/or try any of the solutions you are provided with - for free - here or is the purpose of your post simply to vent your ideas on how you EXPECT expect everytning to work and then continue doing it "your way"?

    Several times now you've been shown the correct syntax to access any pin using an offset and it's (for example, using PortA.0 as the "base address") PortA.0[offset] and yet you ask if PORTA+A will work, I'm sorry but I don't get it. And to be perfectly clear, no, PORTA+A will not do what you want.

    So in your example:
    Code:
    FOR A=1 to 20
     HIGH PORTA.0[A]
    NEXT
    I would not use HIGH though but instead PORTA.0[A] = 1 since that will produce smaller and faster code and it will work provided TRIS are cleared for the pins in question.

    /Henrik.

  8. #8
    Join Date
    Feb 2013
    Posts
    1,153


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    Well you're the pros, for me a lot of these strange brackets and other syntax things are quite hard to understand, because I've learned BASIC on ZX Spectrum, almost 35 years ago So I'm asking to clarify.

    So back to this:


    FOR A=1 to 32
    PORTA.0[A]=1
    NEXT
    Will make all ports of PORTA/PORTB/PORTC/PORTD high in sequence, right? (All TRIS and other yada-yada are already set).

Similar Threads

  1. How to do the "SerIN" and "SerOut " for the usb ?
    By vicce67 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th March 2015, 02:01
  2. Replies: 0
    Last Post: - 14th November 2013, 03:32
  3. Replies: 3
    Last Post: - 15th October 2012, 08:06
  4. AN Question for "word" variable read The serial port
    By redfoen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th December 2007, 17:39
  5. Replies: 1
    Last Post: - 16th February 2005, 20:05

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