Objectinfo "procedures" Not Working

I tested Jim’s Code as he provided it and followed his database setup. But it is very easy to follow his example to get formulas, too.

First you add an additional field “Formula” to your analyzing database. Then you add one line of code above the procedure line that delivers the code:

Formula = objectinfo("formula",objectNumber,formName,scanBase)

I think my post was a little confusing. I want to retrieve and assign the procedure (not the formula) for each object. But I cannot get the procedure. Jim’s formula in this line of code,

Code=objectinfo("procedure",objectNumber,formName,scanBase)

is not returning anything. It’s empty. Everthing else is working as expected.

Also I cannot get the formula; it is also empty.

1 Like

I have a feeling this might be an OS X version anomaly. On my 10.13.6 old iMac I get the same results as Tom and Vic in that I could not get a return for either “procedure” or “formula” from an object on a form unless I was actually trying from a procedure in that actual database. If I try to farcall that same procedure from a second database it will then gives an empty return for these items as well.

Ok, I found a way to get it to work for me by adding an additional line of code to the procedure. Simply add this magicformwindow statement to the first part of the looparray block:

deleteall
looparray dbinfo("Forms",scanBase),cr(),formName
    let objectNumber = 1
    magicformwindow scanBase,formName
    loop
………………rest of existing code follows

Gary, I am amazed that you can think of such things. I don’t think I ever would have figured this out. It doesn’t seem like it should be necessary since the objectinfo( function already specifies the form and the objectID in its parameters. Thanks.

Tom, Jim’s procedure is working here perfectly indeed. I am using macOS 10.14.5.

I will add this difference to the list of mysteries of Panorama X and move on to something else.

Hello Gary,

When I add your magicwindowform statement as you indicated, my running procedure stops at that line with an error:

magicwindowform error: Instructions form in Compass Bank
database is not open

“Instructions” is indeed the first form in the database. But although Jim’s code opens the database, it does not open the forms. Is there a missing “Openform” command?

image

You are correct in that I did not fully test this on forms that were not already open. I have added a trap to open a form if it is not already open and then return to the data sheet at the end.

deleteall
looparray dbinfo("Forms",scanBase),cr(),formName
    let objectNumber = 1
    If arraysearch(info("formwindows"),scanBase+{:}+formName,1,cr())=0
        openform formName,"Database",scanBase
    endif
    setactivedatabase "Untitled"
    magicformwindow scanBase,formName
    loop
    ……………additional code
    endloop
endloop
opensheet

Unlike the original method that is not working completely in some OS X versions, this will require that the forms must be open when gathering the information.

This was discussed earlier in this thread, before I posted my code. In fact this was the original topic of this thread. I also mentioned this when I posted the code, I said “to use this you should call this code from a button in a form”

When you try this code you should add a form to the database with a button to launch the code. Always run the scanning code from this button, not from the Action menu or the Run button in the procedure code. If you run this scanning code with the data sheet active, you’ll see exactly the symptoms described – items like procedure code, formula, etc. won’t be retrieved.

Vic, what is the name of the database you want to analyze?

Your error message is talking about a “Compass Bank” database, but your screenshot shows that you defined a database “A” as scanBase:

let scanBase = «A»

Jim, KJM, Gary,

Jim: I am running your code from a form button. The button has a procedure that is simply “Call «Procedure_A»”. Although your code returns the object name, it does not return the procedure text.

KJM: the database I defined is «A», not “A”. «A» is the first field of my test database, which contains the name of the database (“Compass Bank”).

Gary: There has to be an extra step to close the form window. Otherwise, all form windows of all databases will be open at the end of the macro. There may be dozens. A problem I was having, however, was when opening and closing form windows, I corrupted the file. Jim wrote his code to AVOID opening and closing form windows. But now, it looks like I’m back to where I was at the beginning. If I start opening and closing each form window, I may corrupt the file again.

The solution to this, Jim, is to make the objectinfo("procedure function work like the “name” function. Is that what you can do?

Vic

Here is my last attempt at getting this straight and make up for not fully reading the earlier posts about using a button in a form. This iteration of the code will allow it to be run from the datasheet. By using a progressalert as a form in front of the datasheet and it seems to allow for full work-ability. No forms need to be opened or closed just as Jim had written it.

local pinfo,x,max
pinfo = initializedictionary(
    "SHEET",true(),
    "TITLE","Gathering Info")
max=100
for x,0,max
    progressalert pinfo,x,max
endloop
let scanBase = "Test" // substitute the name of the open database you want to scan
deleteall
looparray dbinfo("Forms",scanBase),cr(),formName
    let objectNumber = 1
    loop
        let oClass = catcherror("",objectinfo("class",objectNumber,formName,scanBase))
        stoploopif oClass=""
        if Form<>""
            addrecord
        endif
        Form = formName
        Object = str(objectNumber)
        Class = oClass
        Name = objectinfo("name",objectNumber,formName,scanBase)
        Code = objectinfo("procedure",objectNumber,formName,scanBase)
        objectNumber = objectNumber+1
    endloop
endloop
progressalert pinfo,-1,max

Gary,

I haven’t tried your code yet. But isn’t the form window with the starting button already “a form in front of the database”? Why is a progress window needed for that purpose?

Time to call it a day.

Vic

No. No form windows need to be open in the database being scanned. You just need one form open in the database that contains the scanning code. Or you could use Gary’s clever solution, which relies on the fact that the progressalert statement opens a form.

I don’t understand this. Doesn’t this database contain lots of records? Do all of the records contains “Compass Bank” in the A field?

The last code version was so you would not need another form in the searching database with a button on it. You would simply run this code directly in the datasheet from the Action menu.

Hello Gary, Jim,

Yes, I understand that, Gary. But doesn’t the fact remain that the form with the Start button is already in front of the active datasheet? What is the need for a second form in front?

The first record has “Compass Bank” in the first field. And that is where the active cell is, so the statement

let scanBase = «A»

results in «A» = “Compass Bank”. And that is the database that opens on screen. And that is the database whose forms appear in the datasheet of “PanX Test Pilot”. And the added records properly show the Name of each object on each form of “Compass Bank”. I run the macro from the Start button on a form. No form windows pop up or close during the macro. Everything works as it should, EXCEPT that the procedure text is not there.

Eventually, when all database names are in the datasheet, I will loop to open each database in turn. For now, my Test Pilot database starts with only two records, but I don’t yet have a loop to check the second database.

Is my problem an OS problem? I am still on OS 10.11.6. Jim seems confident that as long as the code is run from a form button, everything will work correctly. But that is not what is happening.

Vic

The whole idea was so that you did not need to create the form with the button at all. Using my code you only need to have a database with the datasheet and one procedure containing the scanning code. Then in the datasheet you would run that procedure from the Action menu to populate the datasheet fields. No additional form is used at all.

Separately from the conversation on this forum, I actually sent Vic a database with this code that already had the form with the button. And yes, Vic, that should be all you need. That database worked perfectly on my machine when I sent it to you, all that needed to be done was to change the name of the scanned database on the first line of code. The database I sent you is not the only reason I am extremely confident that the objectinfo( function works when a form window is the current window. This is part of my regular workflow. Whenever I get a section of form design or code working, I use the View Wizard to export the affected library or wizard databases as blueprints. The blueprint saving code uses objectinfo( to do the export. I then use the Git source control system to keep track of exactly what changed. If the objectinfo( function failed, that would show up right away in my Git change history. I’ve been using this technique regularly (up to several dozen times a month) for over 5 years, going back to at least OS X 10.9. So yes, I have a lot of confidence in this, it’s a very frequently used part of Panorama X for me.

Sorry, I did miss the earlier comment.