ImportDictProcedures statement does not create a valid dictionary

When I run the following code I get an error message, “dumpdictionary( function parameter must be a valid dictionary”.

local alpha, beta
ExportAllProcedures "",beta
ImportDictProcedures beta, alpha
clipboard = dumpdictionary(alpha)

I get the same message if I use saveallprocedures and loadallprocedures.

Can somebody please test this for me - preferably in High Sierra? I’ve recently upgraded to High Sierra and a few things that used to work don’t now. I have OS 10.13.3 which I think is the latest iteration.

I’ve just tested this on my MacBook and I get the same result as I had on my iMac. Can somebody please check this for me?

Confirmed. I get the same error when running your procedure with macOS 10.13.3. The variable beta is being loaded with the procedure text correctly, so problem seems to be in the ImportDictProcedures statement.

Can somebody test if it behave differently in an earlier OS?

This statement is completely non-functional, turns out it wasn’t really ported from Panorama 6. I guess I neglected to test it and no one has tried it before today. I have reworked the code just now, it now works so the fixed version will be in the next release.

I have traces of egg on my face - when I proof-read the Help wizard, I skipped the dictionary entries because I had never used dictionaries and I was reluctant to make corrections to something I knew nothing about.

Is there a scheduled date for the next version? I’ve been waiting on this fix since December.

Panorama releases are generally not announced in advance. The next release is getting closer, but not really imminent. I’ve paused working on it to reply to this message!! :slight_smile:

If you can’t wait, I’ve included the new working code for this particular statement below. It’s only about a dozen lines of actual code, so you could easily incorporate it into whatever database needs it.

However, as mentioned in the documentation, for new applications I would generally recommend using blueprints instead of using exportallprocedures/importdictprocedures.


/*
<PROCEDUREINFO>
<description>converts source code exported by the [ExportAllProcedures][] statement into a dictionary.</description>
<breadcrumb>Panorama>Procedures>Procedures</breadcrumb>
<tags>procedures</tags>
<parameter NAME=SOURCETEXT TYPE=TEXT>Source code that was exported with the [ExportAllProcedures][] statement.</parameter>
<parameter NAME=DICTIONARY TYPE=TEXT>Field or variable to store result in.</parameter>
<body>This statement converts source code exported by the [ExportAllProcedures][] statement into a dictionary. This dictionary can be used with the [LoadAllProcedures][] statement.

This example transfers all of the procedures from the current database into some other database.

    global psave
    exportallprocedures "",psave
    ...
    ...
    ...
    ...
    window "Some Other Database"
    local psDictionary
    importdictprocedures psave,psDictionary
    loadallprocedures psDictionary</body>
<seealso>@procedures</seealso>
<history><revision version="1.0" status="No Change">Carried over from Panorama 6.0.</revision></history>
</PROCEDUREINFO>
*/

local procedureNames

let rawSource=lftocr(parameter(1))

let rawSourceArray=tagarray(rawSource,"___ PROCEDURE ",¶+"___ ENDPROCEDURE ","+++++++++++"+cr()) // chr(1))

arrayfilter rawSourceArray,procedureNames,"+++++++++++"+cr(),
    import()[1,search(import()," ____________")][1,-2]

let procedureDictionary=""
looparray procedureNames,"+++++++++++"+cr(),procedureName,procedureNumber
    let procedureCode = array(rawSourceArray,procedureNumber,"+++++++++++"+cr())
    procedureCode = arrayrange(procedureCode,2,-1,cr())
    setdictionaryvalue procedureDictionary,procedureName,procedureCode
endloop
setparameter 2,procedureDictionary
return

Thanks Jim - that’s great.

There may be an error in your code. The code generates a dictionary of procedures with each entry in this format (this particular procedure begins at the semi-colon):

.Initialize=;               .Initialize         21.8.2017
local I, J, K, L, M, Tim, Hrs, Mins, Secs, FileName1, FileName2, FileNameTest, FixChoice, Bnnn, BnDiff, NumRec
local Array1, Array2, Array3, Window1, Window2, NumPhoneFields1, NumPhoneFields2, Start, FieldName1
local mA, mB, ArrayElement, Temp, Kount1

following which the loadallprocedures statement crashes Panorama X.

Well, it worked in the tests I did a couple of months ago. I won’t be able to look at this in detail for a couple of days, hopefully I won’t forget.

Don’t spend any time on it for the moment - I extracted the heart of your procedure and incorporated it into mine - I may have made an error in so doing. I’ll try it as a call to a separate procedure.

That delivers the same result. I wonder if the loadallprocedures statement is faulty?

I’ve solved the problem for the time being by writing my own loadallprocedures statement.

Yes, I was wondering that also, I’m not sure if I changed that also, so mine might be different from yours. That’s one of the things I was going to look into when I get a bit more time.