My farcall is behaving badly

Sometimes it works, usually it doesn’t. I have a procedure that calculates some data and does a farcall to another database procedure. The first thing that the farcalled procedure does is setactivedatabase to “Teams”. Most of the time it gives an error saying that the field or variable “TeamName” does not exist. There is definitely a field by that name and I copied and pasted from the datasheet into the procedure so its not a typo.
The screenshot shows a bit of code where it went wrong. The findTeamName = Team that is 3 lines up passed the test but this line fails.
Am I missing some special voodoo chant or ritual dance? This is not making much sense to me.
Frustrated in Canadada.

any suggestions would be greatly appreciated

You don’t need to use farcall to do this. You just open the remote database (Teams) in a procedure in “Scoresheets DB” to activate it, and put the contents of your farcall above into that procedure in Scoresheets. I can’t see any reason to have the procedure in Teams as it appears you only ever call it from Scoresheets.

I never use farcall, it confuses me too much.

I would also try quoting the filename “TeamName” that you are having trouble with. Maybe Panorama is getting as confused as me about what it is and which file it is in.

That should be fieldname “TeamName”, not filename.

If you want to leave the procedure in Teams, then you can call it instead from Scoresheets after making Teams the active file in a Scoresheets procedure, like this:

Opendatabase "Teams"
Call "Put Team Scores in for the week"

Farcall enables a procedure in a non-active database to run on and act upon the active database you are farcalling from.

I think there must be an invisible character in the TeamName text on line 20. That’s the only thing that makes sense given that line 17 works ok.

Using farcall has nothing to do with whatever the problem is. Farcall is quite simple and predictable but seems to cause a lot of confusion. People seem to get the idea that since farcall calls code in another database, it would also make that database active. It does not do that - the original database remains active. But in your case you are starting with 1setactivedatabase “Teams”’ so I think you are ok. Your screenshot cuts of the name of the data sheet with 27 records – that is “Teams”, right?

It has nothing to do with your problem, but there is a simpler way to write this loop. Instead of

loop loopindex counter
    X = nthline(Temaarray,counter)
until counter = theSize

You could use

looparray Teamarray,cr(),X

Not only is the code simpler, but it will run significantly faster also.

One other optimization, you can get rid of the local statement and use

let theDate = parameter(1)
let theWeek = parameter(2)
let Teamarray = parameter(3)
let theSize = arraysize(Teamaray)
let pointer = arraysearch(teamStats,theDate,1)

Or even

localparameters theDate,theWeek,Teamarray
let theSize = arraysize(Teamaray)
let pointer = arraysearch(teamStats,theDate,1)

Thank you all. Lot of new ideas to work on today. Jim I very much appreciate you code suggestions. Very helpful to a newbie like me. Assembler Language Programming was so much simpler!

As someone with 25+ years of assembly language experience, there is no way that is true!! The instruction set may be smaller than the vocabulary of statements and functions that Panorama has, but it takes dozens, hundreds or in some cases even thousands of assembly language instructions to perform what a single Panorama statement or function can do.

I just remember being able to perform magic with assembly language 27 years ago. Not so much anymore. Could it be me?

Larry, I recall performing magic with assembler code more than 45 years ago but the “magic” was simple by today’s standards and it was hard, hard work.

Well then it must be my old age creeping (racing) up on me. Still love programming, no matter what.