|
|
This page includes sections on installing, loading, and using the software. Following those are sections on tips for using it, technical notes, and known problems. Installing Memorized CalculationsCopy the Memorized Calculations extension file (mrecalc.avx) into your EXT32 folder. By default, this is /ESRI/Av_Gis30/ArcView/Ext32. (For those of you with custom installations: relative to the folder where the ArcView executable program is installed, this is ../Ext32) Copy any *.frm files anywhere you like: they contain sample calculations that you can load using the Load button. See the Freebies page for detailed instructions. Loading Memorized CalculationsTo make Memorized Calculations available within an ArcView project, choose the Memorized Calculations extension from the Project|Extensions or View|File|Extensions dialog by checking the box next to its name.
Using Memorized CalculationsThe example in this section is based on ESRI's "cntry94.shp" file of world countries delivered with ArcView. By the end of your first five minutes with Memorized Calculations you will have computed the areas of 165 countries and produced a working, commented 60 line Avenue script to compute the areas again whenever you want. We set the view's projection to equal area cylindrical and saved this as a shapefile in the projected units using ArcView 3.2. It automatically calculated the shape areas when it did so. Here's what the new feature table looks like:
It is difficult to know what to make of these "areas". We will begin by recomputing them--and memorizing the computation. Bring up Memorized Calculations by pressing its button. There are no calculations for this table yet, so the main part of the dialog consists of one blank line, highlighted in black:
The top line consists of headers: "Field," "Formula", "Selection," and so on. (There are actually five more columns to the right, but they are not usually important and have been shrunk to tiny widths by default..)
(You cannot even see the FType, Dec, or Comment headers in this example.) You create or modify formulas by double-clicking right on the place you want to change. Then you make the dialog act by pressing a button. Let's recompute the country areas. In the Memorized Calculations dialog simply double-click within the highlighted row beneath the "Field" header. This will bring up the field selector dialog:
You can see we selected the [Area] field. After pressing the OK button, the Memorized Calculations dialog looks like this:
Now for the formula. Double-click in the highlighted area beneath the "Formula" header. This will bring up the familiar Field Calculator dialog. Here it is, filled in with the appropriate expression for computing areas:
After pressing the OK button, the Memorized Calculations dialog now looks like this:
We will want to make sure that all areas get recomputed. To do this, we will set the selection expression to something that is always true. Double-click in the highlighted area beneath the "Selection" header to bring up the familiar query dialog:
We show it already filled out with an expression guaranteed to be true! here is the Memorized Calculations dialog:
Finally, just to be certain nothing is left to chance, we will set the selection type by double-clicking in the highlighted area beneath the "Type" header:
Select "New Set" and press OK. The calculation definition is complete and we're ready to go:
If you have left the Memorized Calculations dialog in its default state, your query and calculation expressions were tested as you entered them:
Notice that the "Save on exit" checkbox is checked. This means you have done some work that may be worth saving. Memorized Calculations will offer to save your work, if you do not think to do so, at the time you close its dialog or switch to working on a different table. Although your new formula was tested, it was not actually applied--that is, your table has not yet been changed. Now is the time. Simply press the Execute button.
The status line shows what happened (it should have been fast):
Look at your table. You will see that all its records are selected. The [Area] values have changed:
Those are huge numbers! I think they are square meters--that is the default units ArcView uses for projected data. Square kilometers would be easier to read. Let's make the change right in the Memorized Calculations dialog. Just double-click on top of the "[shape].ReturnArea" formula. As before, this brings up the Field Calculator dialog. Put your cursor in the text box and press ctrl-V to paste the old formula in. Then continue typing to modify it:
Rather than executing the formula immediately, this time we will write an Avenue script to carry out this area calculation for us. First let's add a comment to this formula. Press the Comment button and fill out the dialog. Now simply press the Compile button. You will be asked to name your script. Let's call it "Countries.ReturnArea":
Press OK. To see your new script, scroll to the Scripts icon in the Arcview project window, select the script by name, and press the Open button. You may leave the Memorized Calculations dialog open or you may close it. When asked whether to save the changes, say yes.
Click here to see the script that is produced. You can easily modify it to compute the areas for any polygon theme--just change the second line to refer to its feature table:
You can make this script callable from another Avenue script, for example by changing this line to strTable = SELF It would be called by another Avenue script in this way, for example:
Tips for More Efficient Use
Technical NotesThese notes respond to questions you may have after using Memorized Calculations for a while. What is that "rows" listbox for on the left?ArcView's Dialog Designer, with which Memorized Calculations was created, has bugs. Some of them prevent ArcView from recognizing certain mouse clicks within the formulas box. This causes what you see on the screen to differ from what the Avenue code sees. The "rows" listbox serves to confirm the formula selection by listing the row numbers (rows start 0, 1, 2, ...) that are selected. To see the correct selection, simply press the button beneath the rows listbox:
You can make this stuff disappear simply by unchecking the "show row numbers" checkbox (version 1.11 and later). What is the "define" option for the selection type?Normally, a selection expression changes which records in a table are selected--that is, highlighted and available for calculations and other operations. The "define" option effectively makes all the other records invisible. It works exactly like a theme definition. What happens if I don't choose a selection type?It will be treated as a new selection. How do I undo a "define"?Create a new definition that is always true, such as "(true)". What do "Copy" and "Paste" do? They don't seem to affect the Windows clipboard.Copy puts the selected formulas into ArcView's clipboard, which is separate from the Windows clipboard. Paste will insert the copied formulas beneath the last selected formula. If you have copied more than one set of formulas to the clipboard, you will be shown a list of the times (to the nearest second) at which you made the copies. Choose one time from this list. The corresponding set of records will be copied. What is the difference between "Keep" and "Save"?Keep will attach the current formulas (selected and unselected) to the table named in the "Table:" box. Save will create a disk file for the selected formulas only. What happens if an error occurs while executing a collection of formulas?All processing immediately stops, the entire transaction is rolled back, and the status bar is filled with information to help you diagnose the problem. What does "test expressions" actually do?Immediately after you enter a field name, calculation, or query expression, ArcView attempts to execute the formula (or the relevant part of it). Regardless whether the execution succeeds or not, it then rolls back the transaction so that no change to your table is actually made. Can Memorized Calculations work on SQL tables?It will work on anything ArcView can edit from the usual Table interface. That normally does not include SQL tables. However, because Memorized Calculations is useful for making selections as well as doing computations, it is not prevented from running when the underlying table is not editable. If you try to create a new field or enter a formula, however, you will be informed (whenever an execution is first attempted) that the table is not editable. How do I run the script I created?Open it from the ArcView project window, compile it (Script|Compile), and run it (Script|Run).
Known problemsProblem "I got this error when I tried to add the Memorized Calculations extension to a project....Can't convert 'LISTBOX_SELECTION_MULTIROW' to enumeration." I'm using Arcview3.2 (or AV 3.1.1). This problem has been reported by two users (2 June 2000). Solution Your version of Dialog Designer is out of date. You can confirm this with a simple procedure. Load the Dialog Designer extension into a new ArcView project, create a new dialog, add a listbox, open its properties dialog, and double-click the Selection Style property. The valid selection options will be listed. If LISTBOX_SELECTION_MULTIROW is not among them, your version of DD is out of date. The solution is to reinstall the Dialog Designer extension that comes with AV 3.2. The only way we know of doing that is to uninstall and then reinstall AV 3.2 itself, but perhaps you will find a better way. If you do, please let us know.
|
ColorRamp, Memorized Calculations, Rotate, Sample, XSect, and Tissot are trademarks of Quantitative Decisions. All other products mentioned are registered trademarks or trademarks of their respective companies.
Questions or problems regarding this web site should be directed to webmaster@quantdec.com.
|