Copy Procedure with Formula causes C11 crash, alternate way to copy?

I am busy finishing off chapter “12 - Working With Reports” and I have got to the last report:

A Single Invoice Report

Next, we will print a single invoice from the Browse list of orders.

Creating the Report

1.In the Application Tree, highlight the CustInvoiceReport procedure.

2.Choose Application → Copy Procedure.

I type in the name of the new procedure and C11 crashes. I tried the recommended name and a few other names. No go:

Exception occurred at address 11C53189
Exception code C0000005: Access Violation
Process PID=716  Image: C:\Clarion11\bin\Clarion.exe
Thread 2  Handle=00000CA4  TID=7080

Exception parameters:
00000000
00000000

EAX=00000000    EBX=1113EB28    ECX=1113EB28    EDX=00000000
ESI=1113EB28    EDI=1113EB30    EBP=199CF020    ESP=199CE900
EIP=11C53189    FLG=00010212

Call Stack:
11C53189
11CAF1C7
08FAD3E1
772A7C7E
772A7C4E

Clarion modules:
08EE0000  11.00:13372 C:\Clarion11\bin\ClaRUN.dll
08EB0000  11.00:13372 C:\Clarion11\bin\ClaIde.dll
11B30000  11.00:13372 C:\Clarion11\bin\ClaASC.dll
11B50000  11.00:13372 C:\Clarion11\bin\ClaDOS.dll
11AC0000  11.00:13372 C:\Clarion11\bin\ClaDEF.dll
11980000  11.00:13372 C:\Clarion11\bin\ClaTPS.dll
118E0000  11.00:13372 C:\Clarion11\bin\ClaCBC.dll
11920000  11.00:13372 C:\Clarion11\bin\Claasl.dll
11E10000  11.00:13372 C:\Clarion11\bin\ClaAPP.dll
11C50000  11.00:13372 C:\Clarion11\bin\Clagen.dll
1CEA0000  11.00:13372 C:\Clarion11\bin\ClaDSI.DLL
1CDA0000  11.00:13372 C:\Clarion11\bin\Cladct.dll
1CFB0000  11.00:13372 C:\Clarion11\bin\ClaPRJ.DLL

I have tried restarting the PC, recovering the application, etc. It compiles without any issues, so I have run out of ideas.

Any suggestions on how to copy a procedure without using the Application menu?

On the Application menu…
Selective Export to TXA and pick that one Procedure
Open TXA in the Editor
IIRC the first line will be [PROCEDURE] and the next line will have its Name … Or find the Name
Change the Name to the new name
Save TXA
Import the TXA

If you don’t edit the name I think the import warns you and offers a Rename button.

I copy procedures all the time in 11.13505. You could try export your entire APP to TXA, create a new APP from that TXA

1 Like

The export crashed too. I will try exporting the whole application but I’m not going to hold my breath.

Does the procedure have embed code?

Look at it and see if any start with [ brackets]?

OMIT sections, delete them.

Anything unusual?

Yes. A small amount. I will remove the embed code. I think the lesson requires me to do it anyway.

It’s amazing how much I have learnt from your suggestions already. Much obliged.

I will also remember to make regular backups. I didn’t think I would need to for the “Learning Clarion” application, but there you have it

Hello,
I have noticed that COPY procedure fails for me too. I am in the habit of copying a procedure before butchering it; i mean adding/restructuring etc…

The copy process ALWAYS fails on procedures that have formulas that were done through the FORMULA tab of the procedure. Deleting them, after adding them manually to the closest embed point works.

1 Like

Formulas are very fragile when exporting to txa.

1 Like

I have never understood the draw that would make someone choose a formula vs just coding it.

For someone unfamiliar to Clarion, it seems to take just as much effort to learn how to add a formula as it would to code it in the first place.

Are there any advantages to using formulas over coding?

No advantage whatsoever!

I have reported this as a bug:
http://problemtracker.softvelocity.com/UpdtCustBugsview.php?ID1=43224

Looks like one of my PTSS: View Record (softvelocity.com)

1 Like

This Formula problem came up on Comp.Lang.Clarion 08/24/2021 Subject: Re: Export or Copy of procedure does not contain formulas Clarion 11.0.0.13244. A question from @dave.wilkin was to how to find and remove all the Formulas from an APP.

My suggestion is to edit the templates that generate the Formulas code to add a comment !FMula ProcedureName . The Formulas are generated by #GROUP %ExpandFormula in Standard.TPW and ABGroup.TPW. The template code is below. On the end of a 3 lines I added: !FMula %Procedure

#!-------------------------------------------------------------------------
#GROUP(%ExpandFormula,%CurrentElement)
  #DECLARE(%LastElement)
  #SET(%LastElement,INSTANCE(%FormulaExpression))
  #SELECT(%FormulaExpression,%CurrentElement)
  #CASE(%FormulaExpressionType)
  #OF('=')
    #IF(%FormulaExpression)
%Formula = %FormulaExpression                           !FMula %Procedure  <-- FixMe --
    #ELSE
CLEAR(%Formula)
    #ENDIF
  #OF('IF')
IF (%FormulaExpression)                                 !FMula %Procedure  <-- FixMe --
  #INSERT(%ExpandFormula,%FormulaExpressionTrue)
ELSE
  #INSERT(%ExpandFormula,%FormulaExpressionFalse)
END
  #OF('CASE')
CASE (%FormulaExpression)                               !FMula %Procedure  <-- FixMe --
#INSERT(%ExpandFormulaCase,%FormulaExpressionCase)
END
  #ENDCASE
#!-------------------------------------------------------------------------
  1. Search the CLW’s for the !FMula. Results will be formula lines with Procedure name.
  2. Open Procedures in the Embeditor and find !FMula
  3. Copy that generated formula code into a nearby logical Embed point
  4. Exit the Embeditor and Compile to be sure the new embed code is correct
  5. Open the Procedure and Delete the Formulas

In Discuss.SV Geoff Bomford of Comformark.com.au attached the below Utility template below. It generates a CSV file with %Procedure,%Formula,%FormulaDescription,%FormulaClass. You could open that in Excel as a work list.

GWBFormulasList.zip (904 Bytes)

I would probably do both. If your solution is composed of multiple APPs using my way a single Solution build will generate !FMula tokens in every APP. A search for FMula will tell you all the APPs that need fixing. Then in those APPs generate the Utility template.

A further template change would be in %ExpandFormula to add the below message so in the output you would see a warning:
#MESSAGE('Formulas were used in ' & %Procedure )

2 Likes

Thank Carl,
That is so useful!

Or, omit the ! and let the compiler find it for you :slight_smile:

1 Like

I remember that being a DAB-suggested technique that has worked very reliably, whether I liked it or not. :slight_smile:

I like to use that method also, like if I want to change a prototype or name.

I would guess in this case the IDE will locate the error in the Module and not the Embeditor. It’s worth a try.