FarCall Behavior vs. the Active Window

If I initiate the arraybuild in the AR file (sending a request, via FarCall, for the Cus IDs of a set of customers with a given last name), the open window for the “FarCalled” procedure gets halted with what appears to be an alert “Field or Variable [L Name] does not exist”.

FOR A WHILE THE FOLLOWING WAS TRUE, BUT NO LONGER: “Surprisingly, the array (“garry”) appears as it should in line 3 of the AR file procedure, IF you disable line 1, and just check in with line 3.”

If I initiate the arraybuild inside the customer file (instead of with the FarCall from the AR file), it goes though without complaint. I worry about some unknown monkey wrench.

BTW, I feel as though PanX is running far slower (molasses-style) on what is a brand new machine, than what I was used to with v6. A video screen capture of this simple procedure can document this.

FarCall does not make the other database active. It retrieves the procedure from the other database, and runs it in the current database. Your current database didn’t have a field named “L Name” and that’s why you got that error.

In this situation I don’t think you should use a farcall statement. Instead, I would suggest that you use these two lines.

topdatawindow "WBPS Customers"
call "In Process"

Nothing at all surprising about that. When you create a global variable, it continues to exist until you quit Panorama. You must have run the In Process procedure from the WBPS Customers file, perhaps from the Action menu. This created the global variable and set up the value. Later, when you just ran line #3 in the other procedure, it simply displayed the value that had already been set up in the garry variable.

In this case I suspect this entire subroutine is unnecessary. You could replace most of it with an arraybuild( function with the query option. You could also use the database parameter in this function so that you don’t need to make a window in WBPS Customers active (unless you actually need the records to be selected in that file).

Actually, I see that you are already using the query option with the arrayselectedbuild statement. Why? You already did the selection.

Also, you aren’t handling the situation where no one matches the name that was entered. First of all, you need to use info(“empty”) to check for that, not info(“selected”) ≤ 1. Secondly, if there is no match, you should not set the array to the customer id of the current record – that would essentially be random (or actually whatever the first record in the database happened to be)

You probably quit and relaunched Panorama, so the global variable doesn’t exist any more.

Global variables should be avoided like the plague. Once created, they hang around and if you forget about them, can cause all kinds of confusing problems. You should especially avoid global variables with short names like you are using here, that’s just asking for trouble. If you must use a global variable, give it a name like wbpsArrayOfCustomerIDs. At least that would be a name you are not likely to reuse somewhere else.

Good to know. I had it backwards, thinking that db A was initiating a procedure in db, to be run in B and collecting the data the A needed.

There’s always a better way to peal this grape. I’d like it to be in the background; all I need is the array.

Because arraybuild seemed not to notice that the selection was already done; I would get my entire customer list, formatted into this array, not the selection. arrayselectedbuild worked.

Point well taken. I made it global because the array had to be filled in the customer db and the first 6 characters copied to the proper record&field in AR db. But your long name is much less cryptic than my own names.

Thanks again for everyone’s attention.

This code should do it. You can use this in any database, no call or farcall needed, just put this into your WBPS Accounts Receivable database. It doesn’t matter what the current selection in the *WBPS Customers" database is, and the selection won’t be changed.

let searchName = ""
gettextdialog searchName,"Prompt","Last Name?"
if info("dialogtrigger") = "Cancel" rtn endif
let customerArray = arraybuild(cr(),"WBPS Customers",{«Cus ID»+"  __"+«F Name»+"  ("+City+")"},«L Name»=upper(searchName))
if customerArray=""
    alert sheet "No customers named "+searchName
message customerArray

Thanks for the sample, Jim. Unfortunately, it still stumbles at line 5: “Field or Variable [L Name] does not exist””

I corrected the “«L Name»=upper(searchName)” in line 5 to “upperword(”, because last names in the customer db have initial caps and searchName needs initial caps. Also in line 5, I reinforced the fact that City was a field, using chevrons. Neither of these worked. The check button passes everything, so it’s in the execution. But if there’s anything wrong with your lines, I don’t see it.

The problem is that the query needs to be quoted. I would write that parameter as

{upper(«L Name»)=upper(SearchName)}

Using the upper( function on both sides of the comparison guarantees that they will be capitalized the same way. You could also use upperword( or lower(, as long as you use them on both sides. Using uperword( on just one side would cause occasional problems. Upperword(“McDonald”) will return Mcdonald.

1 Like

That’s what I get for writing this in the browser without actually trying it at 2 AM.

I thought about this, but since Bill didn’t do that in his original code, I didn’t do it either. But I’d almost certainly do this if this was my own application. Another option would be to use the match operator, which is case insensitive.

{«L Name» match SearchName}

And here I thought that the humble Cricket had been given a lesson, with errors inserted by the Master for the Cricket to find, as a measure of the Cricket’s worthiness .

It still stalls at the same place. I’ve sent zipped copies off to support.

It still stalls because you didn’t incorporate the change Dave recommended (adding { and } around the query formula). Here is the fixed code:

let searchName = ""
gettextdialog searchName,"Prompt","Last Name?"
if info("dialogtrigger") = "Cancel" rtn endif
let customerArray = arraybuild(cr(),"WBPS Customers",{«Cus ID»+"  __"+«F Name»+"  ("+«City»+")"},{«L Name» match searchName})
if customerArray=""
    alertsheet "No customers named "+searchName
message customerArray

This code definitely works, I ran it.

There’s one other change in the code above. When I type the code into the browser, autocorrect changed



alert sheet

There should not be a space (in fact, autocorrect did it again when I typed it into this post).

1 Like

Thanks, Dave and Jim

from Panorama Help:
You can use any formula you want, but don’t forget that the formula must be quoted.

The ice jam has broken free and data will flow. Thanks for staying with me. I’ve learned alot.