Home AMX User Forum NetLinx Studio
Options

Variable data type prefix

I am still in the learning process of programming AMX and I have inherited some code from an existing system. I am trying to comment/clean up as much as I can. Has anyone seen the 'b' prefix used before? The only word that comes to mind is 'boolean'. Example code below.

INTEGER bFireAlarmMuting

Comments

  • Options
    zack.boydzack.boyd Posts: 94
    Thats an int being used as a bool. They're using Hungarian notation to indicate it's only meant to be in two states 1(on) or 0(off).
  • Options
    dmulderdmulder Posts: 3
    Thanks Zack!
  • Options
    zack.boydzack.boyd Posts: 94
    FYI - any integer over zero will evaluate as true. IE:
    IF(nAnInteger){
        //Evaluates true if 'nAnInteger' > 0
    }
    ELSE{
        //nAnInteger evaluates false if == 0
    }
    

    I just put that out there that I often have 'states' stored in integers, with 'Off' being 0, but any other state having an index value. There's a chance that variable started as on or off, but maybe theres a state where the fire alarm was muted but not reset, etc.

    The moral is... just because someone named it as a boolean, doesn't mean it' IS a boolean. If you experiencing issues, might be worth checking.

    Z
  • Options
    dmulderdmulder Posts: 3
    Ah, makes sense. That's for the explanation. I'm not currently experiencing issues but I will keep this in mind if something comes up.
Sign In or Register to comment.