OBJECTINFO( Query

Tell me about it - I turn 83 next week. Yike!!

Hello Gary,

Happy birthday.

Your code example works perfectly, as I knew it would. But something related still puzzles me.

Jim and Dave earlier had suggested the objectinfoarray function, and I was trying to use it. The Help file indicates that that function normally contains one or more objectinfo functions. So far, so good.

But according to the Help file, the second parameter of objectinfo, if missing, must be defined in advance by an “object”, “selectobjects”, or “changeobject” statement. That’s what was hanging me up. How to do that from within the objectinfoarray function?

But I see from your example, and Dave’s as well, that when used in conjunction with objectinfoarray, only ONE parameter is needed for objectinfo, and the second missing parameter does not need an earlier command statement. I had thought that PanX would balk at using objectinfo with only one parameter WITHOUT an earlier command statement to choose the object.

Apparently, the objectinfoarray function automatically selects each object for processing. Akin to the looparray statement. So the missing second parameter defaults to whatever object is currently being processed. Seems logical, once understood. But how did you figure that out?

You’re wise beyond your years, Gary.

Best regards,
Vic

Yes, it examines each object on the form in the current ID order one at a time so there is no need to pre-select objects in advance. When using the objectinfo( function by itself you must have the object already selected or tell it what the objects name or ID is as the second parameter. Note that if I feel I may have a need to use this function on a particular object in the future I will assign it a name to use for identification in that procedure. I mentioned how to set this up previously in this thread.

Reading the help files and paying particular attention to the examples given in each one usually gives enough clarification on usage so that a simple experiment or two will confirm I understand how it works. I have been known to occasionally not read the help info fully or not at all and gone down my own rabbit hole.

Though I think the objectinfoarray( documentation is pretty clear on this, I’ve changed the objectinfo( documentation by adding objectinfoarray( to the list of commands that can “pre-define” the object to be references.

Please keep in mind that Panorama X has over 9,000 pages of documentation. It’s not always possible to mention every possible variation in every place where a feature is mentioned.

By the way, using objectinfo( and objectinfoarray( together was covered in the intensive Panorama X training course. Chances are that was how Gary originally figured this out. This course is not free, but if you want to push the Panorama X envelope to do really advanced work, I think most of the students that signed up for this course agreed that it was well worth the investment.

Hello Everybody,

I am continuing my “Project”, which is to convert a reliable Pan6 database to PanX. I have come across an anomaly with the objectinfo function that I would like to share with the forum. Jim, you may want to do something about this, or not.

You get correct results using objectinfo(“class”, id, formname, database name) - [obviously you must substitute correct values for the last three parameters] - EVEN IF the active window is different from the form window you are querying. The same is true for the “name” property. But, the “procedure” property does not give the correct result. Thus, in the following code:

window "Macro Designer"
    «Parameter 1» = objectinfo("class",objectNumber,formName,scanBase)
    «Parameter 2» = formName
    «Parameter 3» = objectinfo("name",objectNumber,formName,scanBase)
    «Parameter 4» = objectinfo("procedure",objectNumber,formName,scanBase)

where the objectNumber, formName, and scanbase name are different from the active window, the results for parameter 1, 2 and 3 are CORRECT. But Parameter 4 is not. However, this slightly altered code works fine:

t1 = objectinfo("procedure",objectNumber,formName,scanBase)
    window "Macro Designer"   lastrecord
    «Parameter 1» = objectinfo("class",objectNumber,formName,scanBase)
    «Parameter 2» = formName
    «Parameter 3» = objectinfo("name",objectNumber,formName,scanBase)
    «Parameter 4» = t1    //macro text 

The only difference is that the objectinfo “procedure” text is first put into a variable, while the queried form window is still active, and then that variable is entered into Parameter 4. I haven’t checked other property parameters for this effect - only "class, “name”, and “procedure”.

This is not a huge issue, and will be encountered rarely, maybe only by me. And the fix is trivial - as long as you know there is an anomaly with the “procedure” objectinfo property. I don’t know if other objectinfo properties act similarly.

Regards,
Vic

I cannot duplicate this issue, the objectinfo(“procedure” function works perfectly for me in either case.

Wow. I don’t know what to tell you, Jim. I ran the code below two times. The first time, EXACTLY as shown. The second time, with the full expression in the 10th line replaced by t1. The result is shown after the code example.

objectNumber = 0
    loop    //cycle through objects each form
        objectNumber = objectNumber + 1
        t1 = objectinfo("procedure",objectNumber,formName,scanBase)
    //    If t1 ≠ ""
            window "Macro Designer"   lastrecord
            «Parameter 1» = objectinfo("class",objectNumber,formName,scanBase)
            «Parameter 2» = formName
            «Parameter 3» = objectinfo("name",objectNumber,formName,scanBase)
            «Parameter 4» = objectinfo("procedure",objectNumber,formName,scanBase)   //macro text
            addrecord   debug

After full expression in line 10 is replaced by variable t1:
image

In the first run the procedure value is blank (Parameter 4). The second run, with «Parameter 4» = t1, the correct procedure is shown (it is only a test). The “class” and form Name in columns 1 and 2 are correct in each run. The ONLY change to the code between the runs was to replace the full objectinfo expression into with t1.

I can’t understand it. Can others replicate the example?

I can’t. You left too many unknowns.

How does the loop end?
Are ObjectNumber, formName, scan base and t1 variables? I suspect so.
How and where are they created?
Have you tried z

Huh? Which one do you consider line 10?

Your screen shot shows a new record per the last shown line of your procedure IF that’s the last record in the database. But in that case, the previous record shows “Form_A” when it should be “Macro Designer” if formName has the contents you seem to assume it has.

Me neither, but that’s based on what you’ve provided.

Hello Everybody,

I would like nothing more than to be wrong. I’ve been known to be wrong before.

I have distilled this issue into the most elementary components. Try this.

Create two databases, “DB A” and “DB B”. In database A, create one form, “Form_A”, with one object. Assign a procedure to that object, e.g., "message “XYZ”.

In database B, run the following code:

Local t1
openfile "DB A"
openform "Form_A"
      displaydata objectinfo("procedure", 1, "Form_A", "DB A")
 window "DB B"
      displaydata objectinfo("procedure", 1, "Form_A", "DB A")

RTN

The problem seems to be with the window “DB B” line. If I replace window “DB B” with setactivedatabase “DB B” it works properly. If you eliminate the openform “Form_A” line of code the first displaydata window will be blank as well. This seems to indicate that the “procedure” property for objectinfo( only works on the active database. I tested all the other properties using a simple rectangle object and found all these properties all either returned an empty value or a different value in the second displaydata window when using the original code:

***  "Tags"
***  "$ShadowOpacity"
***  "Opacity"     (1st - 100   2nd - 0)
***  "$ShadowDepth"
***  "$ShadowBlur"
***  "$Stroke"
***  "Procedure"
***  "$Fill"
***  "LineWidth"     (1st - 1   2nd - 0)
***  "$ShadowAngle"
***  "$DropShadow"
***  "$ToolTip"
***  "$ShadowBrightness"

Other objects and properties may vary.

Another theory would be that it doesn’t work when the active window is a data sheet.

I just checked and that does indeed seem to be the case. If I add a new form to “DB B” named Form_A and change the line window “DB B” to window “DB B:Form_A” everything then works properly.

Hi Gary and Dave,

Yes, what you write is true. The “procedure” property of objectinfo only works when the queried form is the active window. In which case the last two parameters are redundant. The “class” property works regardless of the active window. I haven’t thoroughly checked other properties.

This is by no means a “show stopper”. It’s a minor deficiency, with a trivial work-around. But, you have to first know that the work-around is necessary.

My goal in pointing out this issue is to continue improvements to make PanX the stable, premier database that Pan6 used to be. (And still is, in my mind!)

I mentioned that Jim might want to do something about this, or not. It probably affects only a small coterie. Perhaps a note in the Help file to caution against this will be enough.

Regards,
Vic

Gary’s experiment seems to imply that it will work if the active window is a form. It doesn’t have to be the same form, or the same database. It does not work if the active window is a data sheet, even if it is the same database.

Hi Gary,

Your reply and my slow typing of my reply overlapped. I didn’t see your response in time.

But there are 2 problems with first opening a form in the second database. Firstly, the second databse might not have a form of its own. And more critically, if your intention is to add data to fields in the second database, having a form window open instead of the datasheet will lead to trouble.

The most salient point, though - you have got to KNOW there is an issue here. The “procedure” property works differently than other objectinfo properties.

Vic

Dave is correct - this is a known bug. Sorry I didn’t recognize it before but since data sheet wasn’t mentioned it didn’t jog my memory. This has actually been on the bug report list for several years because it is quite difficult to fix, it may require a major rewrite of the feature. As long as the current window is a form everything will work fine, it doesn’t matter what form or what database the form belongs to. But it won’t work if a data sheet is the active window, at least for now.