Menu

Aliasing array elements ?

Help
2015-03-04
2015-03-05
  • Jacques Nilo

    Jacques Nilo - 2015-03-04

    Hi all
    I have a program using a DIM ARRAY(40) statement. Each element can either be 0 or 1.
    For the sake of clarity of the code I am wondering if any given array element could be given a more explicit name through an alias statement. For example a command along the following line:
    Dim Array(1),Array(5) alias Name1,Name5 after which I could use Name1 and Name5 instead of the array elements.
    Any trick that could lead to that type of result?

     
  • Hugh Considine

    Hugh Considine - 2015-03-05

    I don't recall ever implementing that in Dim. The best way to assign new names is to use constants. Try something like this:

    #define NicerName Array(5)
    #define OtherElement Array(11)
    

    The compiler should use direct addressing for those anyway, so you won't lose any code efficiency doing this.

     
  • Jacques Nilo

    Jacques Nilo - 2015-03-05

    Thanks Hugh ! This is exactly the solution I was looking for ! As you say there is no alias option for a DIM Array(x) statement (it seems that it only works for variables). But what you suggest is working great !
    Thanks again
    Jacques
    PS: I'll make a new post with a similar question around string variables: perhaps will you have a similar magic trick :-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.