Getting Text List to Dispay a Variable

Well, not quite. The Text List fails to show the variable customerArray. It has no trouble with literal text (“Gold”, “Silver”, “Bronze”). I’ve search through the Intensive Training videos and the Help file, but found nothing to say that there’s any special magic to get it displayed in the text list.

I do have the variable name entered in the List’s formula pane, and at the point where the array for the variable is created, the variable does display in a message. Anything else I should look for?

TIA

Did you try

ShowVariables customerArray

Also, customerArray appears to be a local in your other thread. If you want to display it in a form, make it a FileGlobal.

1 Like

I’d already tried the ShowVariables both before/after the open form (form name). I’m betting your stipulation of FileGlobal will do it, AND it just now did!

I was assuming that, even with the variable a local (in Jim’s helpful lines), it would have remained long enough to stay through the opening of the form which was expecting it and could use it. Guess not. Nice to know.

Now on to the next step of stripping the Cus ID from the form’s SelectedValue>Value and applying it to «CUS ID». Hopefully, that’ll be straight forward.

The scope of a local variable is limited to the procedure that creates it. Even if the form opens while the procedure is still running, the form won’t know it exists. Likewise, the procedure that declares it could call another procedure as a subroutine. The subroutine won’t know the variable exists, but when it returns to the calling procedure, that procedure will still know it exists.

A lot of these details are covered in “The Life Cycle of a Variable” on this page:

Also, the “Fields & Variables” video discusses this in great depth (however this is not a free video).

That help page is a wonderful reference. For completeness cache() should be, at least, included in its See Also list.

1 Like

I had a good phone conversation and am back here, convinced that behind this current closed door, the remaining steps will be short and easy.

At this point, the variable containing the customer IDs (plus other identifying info necessary for the choice of customer) is formed nicely, but still fails to show up in a Text List form (“PickanID”). The ShowVariables statement is the line immediately following "openform ‘PickanID’ ".

“pickanID” complains if I don’t put customerArray in its formula pane (“missing operand”). But whatever purpose the array name serves, mentioned in the Formula pane, it’s not the missing key that will display the array.

Your suggestions are always valuable. Yes, I’ve done this.

Any ideas?

TIA

Can you show us a screen shot of that formula pane, and the text of the procedure that opens the form?

The procedure text:
letfileglobal customerArray = arraybuild(cr(),“WBPS Customers”,{«Cus ID»+" __"+«F Name»+" ("+«City»+")"},{«L Name» match searchName})
;message customerArray
if customerArray=""
*alertsheet "No customers named "+searchName
return
endif
message customerArray
openform “PickanID”
ShowVariables customerArray

The screen shot

(I also threw the “ShowVariables customerArray” statement in the Code pane, but that has no effect. ±)

Have you tried displaying your array in a Text Display object to be sure it actually has content?

I deliberately truncated the names in my list for privacy, but the basic premise is all still the same

So far, the only way that I have found to make that list come up completely empty, is to put something in the Query box in the Text List Options.

Maybe a screen shot of your Text List Options will give us a clue.

He’s using a Message statement for that.

“Selected Value” is ready to receive the selection. Navigator probably is unnecessary, because what it synchronizes the DB to in this form is not a record in the DB, but an element in the array.

Thanks again for your attention.

It is not probably unnecessary, it is absolutely wrong. This option must be unchecked if you are displaying the result of a formula, which is what you are doing. I’m kind of surprised your list is working at all, but with this option set it will not fill in the value (because the value would be the current database record).

I used to do that a lot, but a new feature recently added to 10.2 makes this unnecessary in most cases. It works with any type of object that uses a formula.

That has only recently been checked during this whole saga. Now unchecked, the list displays in Graphics Mode but NOT in Data Mode.

Yes, it’s surprising that this works at all. At least up to this point everything is working. And from here the steps are simple: strip out the 1st 6 characters and paste that in the «CUS ID» field.

I’m assuming the value box is the place to put an output variable.

Been hitting the books’n’vidoes, but I’m back again. The original challenge was, in entering a new invoice in the AR file, the look-up of a customer ID from the Customer file, to handle the situation where more than one customer in the Customer File has the same last name (but different ID) than the customer whose invoice you’re entering in the AR file, and how to procure the desired customer ID for this invoice.

The below (“3d Time”) works fine as a standalone procedure with the AR file’s input (new record) form. I’ve split the 3 scenarios (no such name, one name, more than one name) into an elseif construction.

     |||||-----------------

let searchname = “” //clean slate for local//

gettextdialog searchname,“Prompt”, “Last Name?”
if info(“dialogtrigger”) = “Cancel”
rtn
endif

let CustomerIDArray = arraybuild(cr(), “WBPS Customers”, {«Cus ID»+"……"+«F Name»+" ("+«City»+")"}, {«L Name» match searchname})
;message CustomerIDArray //confirms array
;message CustomerIDArray[1,6] //confirms value for «CUSID»

If CustomerIDArray= “”
message “Try Again?”
rtn
elseif arraysize(CustomerIDArray,cr()) = 1
message “Jes’ one”
«CUS ID» = CustomerIDArray[1,6]
;message «CUS ID»
elseif arraysize(CustomerIDArray,cr())>= 2
message “Too Many”
rtn
endif
-----------------|||||

However, this procedure really wants to be executed once «Name» has been filled out in the Input form. It wants to be in the procedure pane of the Properties panel for «Names»'s Text Edit Object.

For that very little has to be changed except for the “Name” value (in the standalone: “searchname,” in the TEO: «Name»). I ditched the standalone’s query ({«L Name» match searchname}) for a straight lookup, for this reason.

     |||||-----------------

let CustomerIDArray = arraybuild(cr(), “WBPS Customers”, {«Cus ID»+"……"+«F Name»+" ("+«City»+")"}, {lookup(“WBPS Customers”,«L Name»,«Name»,«Cus ID»)})
message CustomerIDArray
message CustomerIDArray[1,6]

if arraysize(CustomerIDArray,cr()) = 1
message “Jes’ one”
«CUS ID» = CustomerIDArray[1,6]
message «CUS ID»
endif rtn
if arraysize(CustomerIDArray,cr())>= 1
message “Too Many”
endif
-----------------|||||

Because the procedure isn’t executed until tabbing out of that field, the “name” value used in the array’s lookup query, it should be available. But I get the alert “Field or variable ‘Name’ does not exist”.

Even if I try to employ a "Call ‘3d Time’ " in the procedure pane (which DOES work as a standalone) it says the procedure doesn’t exist ("Call Statement Failed, procedure 3d time does not exist.

Any hints will be appreciated.

Here is your formula:

let CustomerIDArray = 
    arraybuild(cr(), “WBPS Customers”, 
        {«Cus ID»+"……"+«F Name»+" ("+«City»+")"},
        {lookup(“WBPS Customers”,«L Name»,«Name»,«Cus ID»)})

The query formula is completely wrong. Here is your original query formula, which worked.

 {«L Name» match searchname}

Here is a revised version of your code which should work.

let searchname = Name
let CustomerIDArray = 
    arraybuild(cr(), “WBPS Customers”, 
        {«Cus ID»+"……"+«F Name»+" ("+«City»+")"},
        {«L Name» match searchname})

There are two problems with the query formula you wrote. First of all, this formula references the Name field, but there is no Name field in the WBPS Customers file. The query formula can only reference fields in the database from which the array is being built.

Secondly, the query formula must return a boolean (true/false) result. If it didn’t fail because of the incorrect field, your lookup( formula would return the Customer ID value, which is not boolean.

At this point I’m pretty turned around and have no idea what "Call ‘3d Time’ " is, but from the symptoms it must be a procedure in the other database. You can only call procedures in the current database.

FYI – don’t use message statements in code that is executed when tabbing out of a field. It messes up the tab action.

1 Like

I’m grateful for your help,Jim.

I now see that the “match” operator returns a boolean T/F. (The exampled queries under “arraybuild(” in the Help System looked like formulas, but my lookup( would have returned text instead of the required T/F.)

“3d Time” was a procedure in the AR file, listed in the Action Menu. Regardless, at this point I’m ready to replace the place-holder message “Too Many”, with the openfolder statement for the TextListObject containing CustomerIDArray. (This is already working.)

This is a left-field fly and not specific to your problem - sort of. Stylistically, I’d recommend NOT defining your file globals in a post-initialize procedure. If it’s a file global, that means you want it “live” for the duration of the open file. And the open file’s birthday is when it is first opened, not several steps later. If for some reason, you were to open your form before that procedure was run, your file global would not yet exist.

In addition, later - months/years later - when you (or someone else) have to fix/modify your routines and are seeking, “Where was the variable defined?” you may have to look through a lot of procedures. So having one place to define persistent variables - those that stick around after a procedure is run - is a good thing.

I’m old school - real old school - so maybe there is not a better place than to old .initialize procedure. But whatever is used, it’s better to put all your file global eggs in one basket rather than have an easter egg hunt later on.

1 Like