Displaying BOOL values in a Browse List as "Y"

Hi all
I am using BYTE fields to store True/False values in a table. The field name is “DefaultYN” and the values are set to True=1, False = 0
I am happy with the CHECK control in the edit form, but I’m not so comfortable with a “1” display in the browse form. I have set the picture to “@N3B” so all the false values are blank.

How do I display this column with a “Y” or check mark if the value is True?

1 Like

You can either go the icon way or just by text. Don’t put the actual byte field in the browse itself, but DO make it a hot field.

If you choose to go with an icon, set the appropriate icon number in SetQueueRecord.

Or you could use a local STRING, setting the value with either Carl’s WingDings pseudo icon idea, (which is neat if you’re not using Anyscreen) OR just set it to Y or N.

O

1 Like

Add icon to browse col.
Set col display to @p pB.
Set icon display based on boolean value.

For Y value.
Use local string variable in browse.
Set table field as hot display.
Set local string according to table field.

1 Like

Define a local variable L:xxx String(3)

In the LIST Format add L:xxx as @s3 and remove the file field

In the embed Format Element for a Browse Queue set the string you want:

L:xxx = Choose(~Pre:DefaultYN,'No','Yup')

As Jeff said in Hot fields best to add Pre:DefaultYN


An alternative …

In the file instead of BYTE you can use STRING(1)

Then on the CHECK you add VALUE('Y','N') so checking stores Y/N not 1/0. So Browse and Report show Y/N with no extra code

That makes the code a bit uglier i.e. IF Pre:DefaultYN = 'Y' THEN ... and easier to get wrong than as BYTE

You also have to default the value to ‘N’ whereas a BYTE gets Zero by default.

2 Likes

Example with List Styles that shows List check boxes without icon files

1 Like

Donn, if you want Y when true and blank when false, you could use @n1~Y~B

7 Likes

Interesting. Never thought or heard of that one.

I added loc:DefaultYN as a local variable, put it in the list, and added it to Hot fields. I just can’t figure out where the embed point is. I did a search for “format”, but found nothing that seemed to fit.

Yes, it is very handy. I often use it in this way @n1~*~B ( asterisk instead of Y)

1 Like

Works like a charm! Thank you.

I got the icon thing to work too, but didn’t like the result. Probably because I chose some rubbish icons.

YourBrowse.SetQueueRecord

2 Likes

I will watch the CIDC2019 presentation again. Thank you.

There are check icons in C:\clarion#\images

SetQueueRecord is an embed you should know where you can adjust what shows in the browse

1 Like

To explain that, the ~ symbols surround the characters that are going to appear in the output, 1 is the total length of the output so there is no room for numbers nor the # signs when the number overflows the picture, it only shows the Y. And when it is zero, the B turns it into blank.

Example:

MESSAGE('/' & FORMAT(0,@n1~Y~B) & '/' & FORMAT(1,@n1~Y~B) & '/' & FORMAT(1432,@n1~Y~B) & '/' )

Shows:

/ /Y/Y/

1 Like

@FedericoNavarro confirmed in a PM that @n3~[X]~B works too, producing [X] when non zero.

I see X or [X] fairly often for a check box. I find the asterisk looks small, in most fonts it is a superscript

2 Likes

I tend to use STRING(1) with values of Y and N these days, which avoids this sort of thing in a browse.

I was just about to post that picture trick myself. :+1:

I’ll post the steps to show a graphic checkbox using a Style and Wingding like below instead of the original “Y”. I did bump the size from 8 to 9. It still looks pretty thin. One nice thing is these are fonts that scale to any size which icons do not do.

image

First you need to decide what Wingding to use. My Repo has a window with several Wingdings that work for Checkbox. The CHR(), Letter and Font are shown.

image

You need to define a Style under Actions like below where I entered the Font, Size as 10 and Style as Zero (meaning N/A, it defaults to 700 = Bold which you don’t want).
Edit: Probably better to enter 400 for Regular. This should NOT require entering a value for Size or Style. I usually hand code these into the embed point.

You can see in the List behind the Form this will be Style number 1, its not totally obvious. You MUST also select the “Run Time Listbox” tab, then select any lists you want to use this style for the List Style code to generate.

image

If you look at the source you will find this style in the DefineListboxStyle ROUTINE (Legacy and ABC). You could skip using App Gen and type this style code in.

image

Open List Formatter and select the Checkbox column.
Change the ‘Y’ in the picture to the Wingding character which is ‘R’ in this case: @n1~R~b@ .
Change the Default Style enter type " 1 " or whatever style number was assigned.
You will see this in the FORMAT string as Z(1)
This style applies to every row in the column so they all are in Wingdings 2. They is also a Cell Style “Y” where you have a LONG in the Queue. You can have both, the Cell Style overrides the Column if its not zero.

image

That’s it, build and run and it should look like the first screen capture.


A further enhancement would be to show an empty box when it is not checked. You cannot do that with a BYTE you must define a Loc:Active STRING(1) and put that in the List with a picture of @s1 plus the Default Style of 1.

In the embed “Format an Element of the Browse Queue (legacy)”, or SetQueueRecord (ABC), you need code like below to assigning the local Loc:Active based on the file value in MBR:Active. Char 163 is an empty check box, and ‘S’ is a different check box.

Loc:Active=CHOOSE(~MBR:Active,'<163>','S')

I modified the list to show this new box on the right of the above @n1~R~b@ example:

image

2 Likes

Hi Carl - Do you know whether the WingDings checkboxes work with AnyScreen on a non-windows client?

I added AnyScreen to my hand coded List Styles example. The below shows AS HTML 5 on the Left does NOT work to show Wingdings 2 font, the normal ABCDEF show.


In the below capture the style does appear to change to Consolas font. The Window font is Segoe UI and the Consolas column “i” is obviously a fixed width "i" . So styles work but not Wingdings or Symbol?


In the below window the Drop List shows Wingdings characters working when specified as a FONT() not as a Style. Maybe there is hope.

LIST,AT(169,28,34,12),USE(Check0),VSCROLL,FONT('Wingdings',14,COLOR:Red),DROP(15), |
        FROM('n|l|p|o|<0A8h>|<0A1h>|<0A2h>|<0FEh>|<0FDh>|<0A4h>|J|K|L')
 LIST,AT(208,28,34,12),USE(Check1),VSCROLL,FONT('Wingdings',14,COLOR:Green),DROP(15)


It did work in the AS Windows Client, although sized smaller.

5 Likes