Let's not forget octal.It would be useful to have the value in Hex as well
When working with some libraries (for example Midi, I am sure there are others) the specification is written with constants entirely in Hex. It would make it much easier to see that the values are correct rather than having to convert them manually.Jokes aside, what's the benefit?
My constants always literally has the same value.the value of showing the value is
Private Const ZERO As Int = 0 ' Standby
Private Const ONE As Int = 1 ' Item entered
Private Const TWO As Int = 2 ' Payment activated
Private Const THREE As Int = 3 ' Payment completed
Private Const ERR As Int = -1 ' Item Not Found
Public Const INTEGER As String = "INTEGER"
Public Const DECIMAL As String = "NUMERIC" ' "DECIMAL"
Public Const VARCHAR As String = "TEXT" ' "VARCHAR"
Public Const eLEFT As String = $"${Chr(27)}${Chr(97)}${Chr(0)}"$ ' ESC a NUL
Public Const eCENTRE As String = $"${Chr(27)}${Chr(97)}${Chr(1)}"$ ' ESC a SOH
Public Const eRIGHT As String = $"${Chr(27)}${Chr(97)}${Chr(2)}"$ ' ESC a STX
Public Const eCLEAR As String = $"${Chr(27)}${Chr(64)}"$ ' ESC @
Public Const eLINEFEED As String = $"${Chr(13)}${Chr(10)}"$ ' CR LF
Same here. I'd go one step further: I don't want to think of their values, of fear that I might enter that into code somewhere. Constants are awesome and make intent and code so much more readable.Most of the time I don't really care about the actual values
Private Const ZERO As Int = 0 ' Standby
Private Const ONE As Int = 1 ' Item entered
Private Const TWO As Int = 2 ' Payment activated
Private Const THREE As Int = 3 ' Payment completed
Private Const ERR As Int = -1 ' Item Not Found
Private Const PAYM_STANDBY As Int = 0 ' Standb
Private Const PAYM_ENTERED As Int = 1 ' Item entered
Private Const PAYM_ACTD As Int = 2 ' Payment activated
Private Const PAYM_COMPLD As Int = 3 ' Payment completed
Private Const PAYM_ERR As Int = -1 ' Item Not Found
Alternative:That definitely surprised me, @aeric ; it does not make sense!
Private Const PAYMENT_ZZZ As Int = 0 ' Standb
Private Const PAYMENT_CLOSE As Int = 1 ' Item entered
Private Const PAYMENT_SO_NEAR As Int = 2 ' Payment activated
Private Const PAYMENT_WOOP_WOOP As Int = 3 ' Payment completed
Private Const PAYMENT_WTF As Int = -1 ' Item Not Found
For your code, perhaps you'd like this also?Sometimes ONE and TWO has another meaning in different Mode activated, in my POS system.
Private Const TRUE As Boolean = 0
Private Const FALSE As String = "Blue"
Public STANDBY_OR_THEOTHER As Int = 0Sometimes ONE and TWO has another meaning in different Mode activated, in my POS system.
My brain is not wired to complex programming like this. This blown away my mind.Public STANDBY_OR_THEOTHER As Int = 0
Even though my example above doesn’t look it makes sense but I can say this is real code I use in my POS system and it is the most important logic to control the sales flow. I call the variable ActionStep. In one point, I need to check what value of this variable and what mode is enabled then enable/disable the user to take next action. For example, once payment is activated, user cannot input item code to search. The input must be the amount with 2 decimals value. It also determines how the Enter button behaves.That definitely surprised me, @aeric ; it does not make sense!
And don't you think that your source, in addition to working the same, would be much more readable by having meaningful constant names?Even though my example above doesn’t look it makes sense but I can say this is real code I use in my POS system and it is the most important logic to control the sales flow. I call the variable ActionStep. In one point, I need to check what value of this variable and what mode is enabled then enable/disable the user to take next action. For example, once payment is activated, user cannot input item code to search. The input must be the amount with 2 decimals value. It also determines how the Enter button behaves.
Just meaningful for me for the time being since I am not planning to distribute or share my code to anyone else. My code doesn't make sense. LOL.And don't you think that your source, in addition to working the same, would be much more readable by having meaningful constant names?