Text Display Object odd behavior

I’m not sure how even to title this odd behavior in a Text Display Object. For this formula…

 lookup("Class Heading Information", "Teacher", gClHdgInfoDB_Teacher, "LongDay", "")+cr()+

datepattern(
superlookup("Class Headers",
{Quarter="Q1" and DayOfWeek=gLongDay},
{WeekThreeDate})
, "dd")

the value in the variable gClHdgInfoDB_Teacher is changed with buttons.

With each unique button push, the displayed text properly changes.

However, if I remove the initial lookup( function and leave just…

datepattern(
superlookup("Class Headers",
{Quarter="Q1" and DayOfWeek=gLongDay},
{WeekThreeDate})
, "dd")

The Text Display Object text no longer changes with each button push.

If your buttons are changing the value of gClHdgInfoDB_Teacher, and it is not in the formula, why would the display have any reason to update?

Reading between the lines, you must have something you’re expecting to see changed in the displayed text, so you’ll need to add something to force it to your buttons, and to the formula. It could be a variable that holds the button name, but is set within the formula to not be displayed. For instance, in the button procedure: info(“Trigger”) = “button1”, and in the Text Display formula, add +info(“Trigger”)[10,11]. The result in the formula is nothing to display, but it is re-calculated.

ShowVariables is often useful too, depending on what else is involved with how your clicks are being processed.

Ignore() function is also useful for getting the result to reflect changes in something which doesn’t directly effect the output value.

Here is the button procedure:

global gLongDay
global gClHdgInfoDB_Teacher
gClHdgInfoDB_Teacher = array(info("trigger"), 2, ".")

let vDatabaseList = "Student Database 26-27" + cr() + "Class Heading Information"

looparray vDatabaseList, cr(), vDBName
    if info("files") contains vDBName
        setactivedatabase vDBName
        select Teacher = gClHdgInfoDB_Teacher
        showpage
    endif
endloop

gLongDay = lookup("Class Heading Information", "Teacher", gClHdgInfoDB_Teacher, "LongDay", "")

setactivedatabase "Student Database 26-27"
showvariables gClHdgInfoDB_Teacher
showfields WeekOneDate
showpage

I’m a little embarrassed to show it as I’m sure it’s extremely clunky.

gClHdgInfoDB_Teacher is set by the button name, which is a teacher’s name.

In my Text Display Object, the first set of code finds the value of gClHdgInfoDB_Teacher in the Teacher field and displays the value of LongDay field.

I don’t need, or want, that data (Longdisplayed in the text display object, but when I delete that first set of code, the text display object stops updating. When I include that code, the text display object updates with every button push.

With the button push, gClHdgInfoDB_Teacher is filled with the teacher name.

The text display object will display the LongDay (e.g. Monday) and the date as a two digit day (e.g. 28).

With each button push, the text display instantly updates:
Monday 28
Wednesday 30
Tuesday 29
etc.

When I remove the first set of code, I get this with each button push:
28
28
28

I would have thought the date would continue instantly updating with or without the first set of code.

So the text display object instantly updates with:

lookup("Class Heading Information", "Teacher", gClHdgInfoDB_Teacher, "LongDay", "")+cr()+

datepattern(
superlookup("Class Headers",
{Quarter="Q1" and DayOfWeek=gLongDay},
{WeekThreeDate})
, "dd")

But the text display object does not instantly update with:
datepattern(
superlookup("Class Headers",
{Quarter="Q1" and DayOfWeek=gLongDay},
{WeekThreeDate})
, "dd")


I have three databases open:
Student Database (student demographics)
Class Heading Information (class day, period, teacher…)
Class Headers (Quarter, day of week, dates of weekly class meetings for the top of the attendance columns)

The roster form (matrix plus text display objects) is n the Student Database.

I don’t understand why taking out the first set of code stops the text display object from instantly updating.


I can get the text display object to update if I switch the form to Graphic Mode, put the smallest edit in the formula, and switch back to Data Mode.

That did it!!!

I put the first set of code, the lookup( function, inside an ignore( function. Now the Text Display Object is instantly updating but only displays the two-digit date.

Still baffled, but at least this works.:slight_smile:

Still baffled, but at least this works.:slight_smile:

A Text Display object will only update the display if a field or variable that is used in the formula has changed value. But a field or variable can be “hidden” from the formula if it is within a quoted section of the formula. Let’s look at your formula that doesn’t work.

datepattern(
superlookup("Class Headers",
{Quarter="Q1" and DayOfWeek=gLongDay},
{WeekThreeDate})
, "dd")

Now you are thinking “I changed the gLongDay variable, and it is included in the formula, so why didn’t the display update?” But that variable is “hidden” because it is inside a quoted text string. The superlookup( function will see this variable when it extracts the formula from the quoted text, but the text display object cannot see it. So the Text Display does not update when the variable changes. I think the best solution is to add an ignore( function like this.

datepattern(
superlookup("Class Headers",
{Quarter="Q1" and DayOfWeek=gLongDay},
{WeekThreeDate})
, "dd")+ignore("",gLongDay)

I put the first set of code, the lookup( function, inside an ignore( function. Now the Text Display Object is instantly updating but only displays the two-digit date.

Still baffled, but at least this works.:slight_smile:

Yes that will work, because the gClHdgInfoDB_Teacher variable is also being modified and that is now visible to the Text Display object. But you are doing an unnecessary lookup( function, which may or may not take up excess time. So I would remove that and go with the solution I provided.


I don’t think you need the showpage after the select statement. You haven’t turned off display, so all this is doing is flashing the display twice.

Also, what is the showfields at the end for? You haven’t modified the WeekOneDate field, so you shouldn’t need to show it.

In fact, the showpage at the end also seems superfluous.


I would always recommend avoiding the use of global variables whenever possible. You are way better off using only local and fileglobal variables if possible.

I’m sorry, but that’s wrong. Changing a field contained in an object’s formula will cause the object to update automatically, but merely changing a variable in the formula will not. For that, you must also do a ShowVariables, and name the variable. In that case, it will update whether that particular variable has changed or not.

In addition to the trick with the ignore( function, you should change

showvariables gClHdgInfoDB_Teacher

to

showvariables gClHdgInfoDB_Teacher, gLongDay

Thank you all for your help and advice with all this. Truly, I’m embarrassed to share my formulas and code as they are the very definition of “quick and dirty.” Very busy year beginning-of-school-year teacher. The lack of elegance and leftover collateral code is great. It’s been several years away from Panorama. This time I hope to stick with it, but the timing getting back into it is pretty poor. :man_shrugging:

With 40 years under my belt with ProVUE and decades of Panorama being my profession, I still manage to have red-faced moments; always have. Some I’ve headed off just before I hit the Post button. But we all have them.