Wish Show constant value

LucaMs

Expert
Licensed User
Longtime User
It would be very useful if hovering the mouse over a constant its value was shown (editing).

Instead of:
1605262722583.png


so:
1605262738743.png




"Workaround":
Press F12 on the constant to go to its declaration, then Alt+left arrow to return back.
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
It would be useful to have the value in Hex as well :)
 

stevel05

Expert
Licensed User
Longtime User
Jokes aside, what's the benefit?
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.
 

Sandman

Expert
Licensed User
Longtime User
So basically, the value of showing the value is when one interface with an external system that doesn't use the same constant (but use the same value). Did I understand that correctly?
 

stevel05

Expert
Licensed User
Longtime User
That is one use for sure.
 

aeric

Expert
Licensed User
Longtime User
? the value of showing the value is
My constants always literally has the same value. ?

B4X:
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
I use constants when I don't like the actual values (e.g. Integer is too small to read) or type (e.g. String values with double quotes)

Recently I have something like this:
B4X:
Public Const INTEGER As String = "INTEGER"
Public Const DECIMAL As String = "NUMERIC" ' "DECIMAL"
Public Const VARCHAR As String = "TEXT" ' "VARCHAR"

Most of the time I don't really care about the actual values.
B4X:
    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
 

Sandman

Expert
Licensed User
Longtime User
Most of the time I don't really care about the actual values
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.

Buuuut, I don't interface with external systems so I don't need to have a mental side-channel where I keep track of whether my constant matches the actual value from the other system.
 

LucaMs

Expert
Licensed User
Longtime User
B4X:
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
That definitely surprised me, @aeric ; it does not make sense! :oops:
B4X:
    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

If they were public constants, I would create a code module: enPaym ("en" stands for ENUM) and remove the PAYM prefix from the constants
 
Last edited:

Sandman

Expert
Licensed User
Longtime User
That definitely surprised me, @aeric ; it does not make sense! :oops:
Alternative:
B4X:
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

Sometimes ONE and TWO has another meaning in different Mode activated, in my POS system.
For your code, perhaps you'd like this also? :cool:
B4X:
Private Const TRUE   As Boolean = 0
Private Const FALSE  As String = "Blue"

Disclaimer: All of this post is a joke. Do not code like this.
 

aeric

Expert
Licensed User
Longtime User
That definitely surprised me, @aeric ; it does not make sense! :oops:
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.
 

LucaMs

Expert
Licensed User
Longtime User
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.
And don't you think that your source, in addition to working the same, would be much more readable by having meaningful constant names?
 

aeric

Expert
Licensed User
Longtime User
And don't you think that your source, in addition to working the same, would be much more readable by having meaningful constant names?
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.
 
Top