Shop OBEX P1 Docs P2 Docs Learn Events
Maximum Characters used in a variable Name? — Parallax Forums

Maximum Characters used in a variable Name?

DavidMDavidM Posts: 630
edited 2010-11-29 07:56 in Propeller 1
HI,

What is the MAXIMUM number of characters that can be used in a variable Name?

I am having a strange problem, I am using two variables which look similar but SHOULD Be considered as Different Variables, Unless there is a character limit

These are my two variables.

SequenceTimePtr
SequenceTimerPtr

I had a look through the manual and its not mentioned!

I believe you can use very long variable names, but the compiler will only use UP TO a certain amount for TAGGING Purposes,

Can someone please show me were the specification for this is?


Thanks
Dave M

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-11-28 23:04
    Those variables look fine (they are different). It's something else. Regarding limit, just enter a very long variable name into the proptool, it complains for 30+. HTH.
  • DavidMDavidM Posts: 630
    edited 2010-11-28 23:05
    HI,

    I just did a test,

    I changed the first character of one of my variables to a "Z" instead of an "S",

    and now the code runs as it should,

    So I conclude that Variable names are not used FULLY during COMPILING,

    ( But I could be wrong)

    regards

    Dave
  • kuronekokuroneko Posts: 3,623
    edited 2010-11-28 23:13
    I only did a simple test (assignment, then check which value stays) but now that you mention it I remember that there is an issue which was discussed in the past. I'll try to find the thread.

    Simple test:
    VAR
      long  SequenceTimePtr
      long  SequenceTimerPtr
    
    PUB null
    
      SequenceTimePtr  := $FF
      SequenceTimerPtr := $80
      dira[16..23]~~
      repeat
        outa[16..23] := SequenceTimePtr
        waitcnt(clkfreq + cnt)
        outa[16..23] := SequenceTimerPtr
        waitcnt(clkfreq + cnt)
    
    DAT
    
  • kuronekokuroneko Posts: 3,623
    edited 2010-11-28 23:32
    http://forums.parallax.com/showthread.php?t=105528

    After re-reading it it may not be related to your issue at all but it sounded familiar (duplication/removal). Do you have more details or a minimal test case? Also, is the generated byte code (*.binary) the same for both (S/Z)? That may be a starting point.
  • DavidMDavidM Posts: 630
    edited 2010-11-28 23:50
    I havent got time to fully test this, I have my code working, I have to finish of the rest of my code as i have a deadline to meet!

    My guess it 8 Characters!

    Anybody else dare to differ!

    Thanks
    Dave M
  • MacTuxLinMacTuxLin Posts: 821
    edited 2010-11-29 00:42
    That's weird. Taking Kye's SD2.0 code as example, a lot of his variables are > 8 char. E.g.

    word rootDirectorySectors, rootDirectorySectorNumber
  • Heater.Heater. Posts: 21,230
    edited 2010-11-29 00:52
    I just compiled that simple test with BST and took a look at the listing output. Seems that BST has no problem with those two variable names and compiles different code for read and write of each one. I have no way to actually run this code here at the momemt but it looks good.

    So at least BST is happy.
    |===========================================================================|
    Objects : -
    Untitled1
    
    Object Address : 0010 : Object Name : Untitled1
    
    Binary Image Information :
    PBASE : 0010
    VBASE : 0044
    DBASE : 0054
    PCURR : 0018
    DCURR : 0058
    |===========================================================================|
    |===========================================================================|
    Object Untitled1
    Object Base is 0010
    |===========================================================================|
    Object Constants
    |===========================================================================|
    |===========================================================================|
    |===========================================================================|
    VBASE Global Variables
    |===========================================================================|
    VBASE : 0000 LONG Size 0004 Variable SequenceTimePtr
    VBASE : 0004 LONG Size 0004 Variable SequenceTimerPtr
    |===========================================================================|
    Object DAT Blocks
    |===========================================================================|
    |===========================================================================|
    |===========================================================================|
    Spin Block null with 0 Parameters and 0 Extra Stack Longs. Method 1
    PUB null
    
    Local Parameter DBASE:0000 - Result
    |===========================================================================|
    7                        SequenceTimePtr  := $FF
    Addr : 0018:          37 27  : Constant Mask Y=39 Decrement 000000FF 255
    Addr : 001A:             41  : Variable Operation Global Offset - 0 Write
    8                        SequenceTimerPtr := $80
    Addr : 001B:          37 06  : Constant Mask Y=6 00000080 128
    Addr : 001D:             45  : Variable Operation Global Offset - 1 Write
    9                        dira[16..23]~~
    Addr : 001E:          37 03  : Constant Mask Y=3 00000010 16
    Addr : 0020:          38 17  : Constant 1 Bytes - 17 - $00000017 23
    Addr : 0022:       3E D6 1C  : Register [Bit..Bit] op DIRA VAR~~ Post-set
    Addr : 0025: Label0002
    11                          outa[16..23] := SequenceTimePtr
    Addr : 0025:             40  : Variable Operation Global Offset - 0 Read
    Addr : 0026:          37 03  : Constant Mask Y=3 00000010 16
    Addr : 0028:          38 17  : Constant 1 Bytes - 17 - $00000017 23
    Addr : 002A:          3E B4  : Register [Bit..Bit] op OUTA Write
    12                          waitcnt(clkfreq + cnt)
    Addr : 002C:             35  : Constant 1 $00000000
    Addr : 002D:             C0  : Memory Op Long POP Address READ 
    Addr : 002E:          3F 91  : Register op CNT Read
    Addr : 0030:             EC  : Math Op +     
    Addr : 0031:             23  : WaitCnt(count)
    13                          outa[16..23] := SequenceTimerPtr
    Addr : 0032:             44  : Variable Operation Global Offset - 1 Read
    Addr : 0033:          37 03  : Constant Mask Y=3 00000010 16
    Addr : 0035:          38 17  : Constant 1 Bytes - 17 - $00000017 23
    Addr : 0037:          3E B4  : Register [Bit..Bit] op OUTA Write
    14                          waitcnt(clkfreq + cnt)
    Addr : 0039:             35  : Constant 1 $00000000
    Addr : 003A:             C0  : Memory Op Long POP Address READ 
    Addr : 003B:          3F 91  : Register op CNT Read
    Addr : 003D:             EC  : Math Op +     
    Addr : 003E:             23  : WaitCnt(count)
    Addr : 003F: Label0003
    Addr : 003F: JMP Label0002
    Addr : 003F:          04 64  : Jmp 0025 -28  
    Addr : 0041: Label0004
    Addr : 0041:             32  : Return        
    
  • mparkmpark Posts: 1,305
    edited 2010-11-29 01:23
    Propeller Manual v1.01 p. 159 (symbol rules):
    3) Must be 32 characters or less.
  • DavidMDavidM Posts: 630
    edited 2010-11-29 01:40
    Well then,

    Thanks for the language reference, hard to find, still doesn't explain the problem!

    Possible SPIN COMPILER BUG??

    Dave M
  • wjsteelewjsteele Posts: 697
    edited 2010-11-29 01:43
    I think we need to see your code. I'm betting that you have a reference somewhere in the code that is stepping on the other one. Possibly an extra or missing @.

    Bill
  • kuronekokuroneko Posts: 3,623
    edited 2010-11-29 01:50
    mpark wrote: »
    Propeller Manual v1.01 p. 159 (symbol rules): 32 characters or less

    Odd, why is the proptool then complaining about 30+? ;)

    Edit: rev 1.1 actually mentions 30
  • DavidMDavidM Posts: 630
    edited 2010-11-29 02:05
    Hi wjsteele,

    As much as i would love to, I cannot post my code, as it is company confidential ( especially where this problem occurred)

    But heres what I know/did

    This OBJECT that I "HAD" the problem in, has been reliable and workings for MONTHS! no changes.

    I needed to change just ONE VARIABLE NAME from "MasterTimer" to "SequenceTimer" as I was modifying my master timer code ( another object) to be more useful, and I like to have descriptive variable names.

    So I did a FIND & REPLACE ( in all of this object) , knowing that I had a few variations of this variable name within this object.


    i.e
    SequenceTimerPtr ( A LONG declared in the VAR BLOCK , which hold the Address of the variable for later use)

    vSequenceTimerPtr ( A reference to an address used to point to the values used in the calling object ( declared in my INIT Method of this object) , this is my standard naming convention)


    So I did the find and replace, and checked each variable name change carefully and then compiled and ran my code, only to discover that my timer was not running, in fact the system froze!

    When I replace the "S" in sequence with a Z, in all the same places, I got the code to function just as it did before.

    I am not using any "@" address references.

    thanks
    Dave M
  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-11-29 06:25
    DavidM wrote: »
    ...

    I am having a strange problem, I am using two variables which look similar but SHOULD Be considered as Different Variables, Unless there is a character limit...


    I've used nothing but very long variable names, very often pushing 30 characters, for the past 2+ years and I've never seen this problem before. But now you have me worried about it. Please keep us posted on this possible bug.

    thanks,
    :)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2010-11-29 06:37
    Dave M,

    Thanks for the heads up. I also like to use discriptive variable names. I can't find mention of which version of the Propeller Tool you're using. Maybe it's a bug that has been fixed in a more recent version. (Or one introduced in a later version.) Which version did you use?

    Thanks,

    Duane
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-11-29 07:56
    I'm confident that this is not a compiler issue. If the compiler were treating distinct, but similar, variable names as the same symbol, it would throw an error when the second "version" of the variable was encountered in the VAR or DAT section. IOW, you can't define the same variable in two different places.

    -Phil
Sign In or Register to comment.