"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
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

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

    So I believe, this "on the fly" port redefine is exactly this particular compiler issue, not general hardware or software limitation.
    the ability to alter a defined constant at runtime would be make a total mockery of sound programming fundamentals .
    changing a constants definition is not a thing .
    runtime allocation of resources is not done that way in any programming language, pbp3 is not particularly adept at it but with a bit of imagination there are workarounds. the sort of output pin manipulation via port alias indexing can do what you desire (as henrik has stated ) .

    while pbp3 has no str type vars it can deal with and create null terminated c-type strings easily, with a little practice and a little skills
    strings can be manipulated in any way necessary with little fuss.


    i would just say one more thing multiplexing ffs
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

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

    Why pin definition should be constant?

    OK say compiler substitutes say code "LD, B(3)" which say means making PORTB.3 high each time I'm making HIGH BUZ because previously I had defined BUZ var PORTB.3

    Now let's say, I want to do dynamic port re-mapping and at one moment BUZ is PORTB.3 and at another moment it is PORTB.4. What compiler should do? During the compile time, instead of replacing all references of BUZ with "LD,B(3)", it just places statement "LD,B(X)", where is X an address say in eeprom or ram, from which, during runtime, the number of port to be made high is being read. And when I need to force this statement to make say PORTB.4 high, I'll write 4 into that address, instead of 3.

    I'm asking of something unusual and not previously done?

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


    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.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,132


    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.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    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

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


    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

  7. #7
    Join Date
    Feb 2013
    Posts
    1,132


    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?

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