Empty Dates again

Hi All,

After reading the posts on this from 2017, I’m confused on how to get the empty dates to work in a find or select command. My 65k record transaction database has some records with VisitDate and ApptTime filled in if it was an office visit and other non-visit records with both of those empty because of the way I build up the record when entering it. (those records would have neither a visit date or appt time and should be blank for clarity)

This line: find «24AvisitDate»=VisitDate AND ApptTime=(TimeSlot-1)*900+lv1

used to work in Pan 6 as it seemed to process all the empty date field records as not matching the query. In Pan X I’m not sure exactly what happens, but if a patient has a record with those empty fields before the existing matching record is found below it, it stops and doesn’t continue on to find the correct record and give info(“Found”) a value of “true”

Do I just have to empty fill all the records and record a default value in the fields going forward, or is there a way to reword the above find statement to work easily.

Thanks,
Scott

I can’t find an explanation for that behavior. An empty date field has a value of 0. If I compare it to 0, it returns true, and if I compare it to any other number, it returns false. I created a database with a date field and 13 records. The first 12 records were blank, and the 13th contained today’s date. When I did a Find, looking for today’s date, it found the 13th record.

It may be that one of the variables in your formula doesn’t have the value you think it does.

1 Like

Dave posted more or less the answer I was going to post. I’ll only add that there is no change in this behavior between Panorama 6 and Panorama X.

Thank you for checking on my issue. This code was not the exact one that “worked forever,” I realized after, but that still left a puzzle that I (think) now is solved.

I realized that in this statement: find «24AVisitDate»=VisitDate AND ApptTime=(TimeSlot-1)*900+lv1 that lv1 was a local variable and I had originally used it in the Calendar DB where it was defined. In the course of modernizing and problem solving had moved it to a new procedure in the Transactions DB, where the local variable didn’t exist. Once I started using a Global Variable, it works as intended.

Happy Sunday

Just to be clear, a local variable is local to the procedure that defines it, not the database. Once the procedure ends, the local variable ceases to exist, even if you are still in the same database. A procedure that begins with one database active, and then moves to another database can continue to use its local variables, even though they may have been defined while the other database was active.

I thought that was the case in the past but the Pan X documentation does not concur. So, I’m still unclear. Here is the copy from the Help file:

If procedure A calls procedure B as a subroutine, procedure B cannot access the local variables created by procedure A.

Here is the calling procedure steps (I always use lv for local, fg for fileglobal, and GV for global):
local lv1, lv2
lv1=lookup(“Mac DO Cal”,“CALDate”,VisitDate,“Start Time”,0,0)
GV1=lv1
lv2=(TimeSlot-1)*900+lv1
GV2=lv2
window “Mac DO Trans:Secret”
call “temp”
If info(“Found”)
message “Found the record”)
etc.

the procedure temp in the transactions DB has one statement:
find «24AVisitDate»=VisitDate AND ApptTime=GV2
or find «24AVisitDate»=VisitDate AND ApptTime=lv2

If I use the local lv2, the error pops up on the bottom of the procedure window: “find formula error:Field or Variable [lv2] does not exist”

If I just change lv2 to GV2 it works as expected. So, I think local variables don’t transfer over. This is a new way Pan X works, I believe. Can either Jim or Dave confirm?

There is nothing new about that. lv2 was defined by the calling procedure. It belongs to the calling procedure, not to temp. temp could create its own local variable named lv2, and it would be an entirely different variable, which wouldn’t have a value until it was assigned one within the temp procedure. That was the way it worked in Panorama 2, and every version thereafter.

If instead of calling the temp procedure, you had simply put the find command in your main procedure, it could have used your lv2 variable. As long as it is in the same procedure that defined the local variable, it can use that variable. The fact that you have made a different database active is not a problem, and never has been.

Thanks for the clarification. I’m on to other procedures and sure will hit some different snags along the way. Cheers

FYI, There is a two hour session in the Panorama Intensive Training course, Fields & Variables, that covers in great detail Panorama’s rules for when different fields and variables are active.

https://www.vimeo.com/160498958

You can find this on the web and also in the Help>Panorama Video Training window within Panorama. It’s not a free video, but it is packed with fundamental information about how variables work.