4th Dimension’s own Commands can be used directly from within Enterprise 6’ macros. For example, the macros can be used for more ‘intelligent’ versions of a global update. The following example is essentially a 4D procedure, but is also a perfectly valid, self-sufficient, if not very useful macro which places the number of Contacts each Company has in its Comments field:
READ WRITE([COMPANIES])
SEARCH([COMPANIES];[COMPANIES]Company Code= "C@")
FIRST RECORD([COMPANIES])
While (not(end selection([COMPANIES])))
SEARCH([CONTACTS];[CONTACTS]COMPANIES' Company Code=[COMPANIES]Company Code)
[COMPANIES]Comments:= [COMPANIES]Comments+char(13)+String(Records in selection([CONTACTS]))+" Contacts"
SAVE RECORD([COMPANIES])
NEXT RECORD([COMPANIES])
End while
UNLOAD RECORD([COMPANIES])
READ ONLY([COMPANIES])
New variables can be created, but you should ensure that their names do not conflict with those used by Enterprise 6 itself. For this reason, always use variable names prefixed with the letter ‘m’: mText:="This is a text variable" or mReal:= 99.99. The := operator is used to allocate a value to a variable.
You can also initiate any Enterprise 6 procedure. Be aware that, in many cases, due to the way in which Enterprise 6 is written, errors may result. The procedures which launch new functions as if from a menu selection are prefixed by ‘Z’, for example ZCompaniesMod or ZDiaryIn. Note that you must have access to the relevant volume containing the function.
The one situation where existing Enterprise 6 variables should be used is when it is necessary to create a variable in a macro, and then to pass a pointer to that variable to a Enterprise 6 procedure. In such a circumstance, it is recommended that the text variables vTitle1 to vTitle20 are used: they are only used in a single area of Enterprise 6 (printed Forms) and thus their use in a macro is unlikely to cause conflicts or unexpected results.
The example below employs this method to bring up a list of Status Codes from which the user can select (as if the wildcard had been entered to the Status field in the Companies entry screen):
vTitle1:="@"
Check MinorNC (»vTitle1;"";»[STATUS];»[STATUS]Status Code;»[STATUS]Status Name;"Status")
ALERT (vTitle1)
The pointer symbol (») is obtained by using the
Some Enterprise 6 procedures have been written especially for use with macros. For example, Picture Dialog is a procedure that displays a dialog box containing a specified Picture, a Title, and Description text. The procedure takes four parameters, and should be called as follows:
Picture Dialog ("CODE";"Title";"Description";"")
The first parameter is the Code of the Picture to be displayed (as stored in the Pictures file in the Data Manager). The second is the Title of the window, which can either be text or can be specified as ‘Picture Name’ in which case the saved Picture record’s name will be used as the Title. The third is optional, and can contain description or instruction text to appear to the right of the picture. The fourth should be left blank. All of the parameters can be variables or evaluated statements.
Note that in order to load significant amounts of text into the Description, one has to create a variable and add to in bit by bit. Consequently, the macro might actually read:
mPic:="Mod Wheel"
mText:="This is a good picture, with lots to look at and talk about"
mText:=mText+", as you are now discovering"
Picture Dialog (mPic;"Picture Name";mText;"13")
The format of the dialog’s Picture is ‘Truncated (non-centered)’. In other words, the picture is not resized, and will be drawn from a fixed top left start point.
Another method of displaying a Picture has also been provided that allows for any size or shape, but with no Title or text attached. Its use is not so automated, which makes it more flexible but more difficult to use.
The following example queries for a Picture, opens a tall and thin centred window, displays it, then closes the window. There is one large highlight button in the dialog that Accepts the window (which can also be done by <Enter> or <Return>).
SEARCH([PICTURES];[PICTURES]Picture Code= "CODE")
Open Any Window (400;200)
DIALOG ([PICTURES];"dPicture Any")
CLOSE WINDOW
Other forms of Open Window Commands can replace the one above:
Open PrD Window ("Title") Top right with Title Bar
Open Pro Window ("Title") 9” or 13” Enterprise 6 record window
Open AnyTypeWin (y;x;type;"Title") Centred, of y & x size, definable type
OPEN WINDOW (left;top;right;bottom;{type};{title};{close box})
Any size & shape Useful ‘type’ numbers include:
0 Just a Title
1 Standard modal dialog, like Confirm
2 Modal with no frame
5 Modal with Title, like Find
8 Title and Close Box, like entry screens
16 Black title, like the Calculator
-720 Floating window with thin title bar, like the palettes
A procedure is also available to ensure that the Name field in the Attendees file consistently contains the correct value - which is the Surname plus the Forename, in that order to allow for sorting. To use it construct a macro which first performs a search to find the right Attendees, then call Attend Name. A further routine checks that all Products in the system have the full Product Code (ie Group, Brand and Model concatenated), and changes any related information in the Orders, Events, Attendees and Invoices files accordingly. To run it, simply construct a one line macro which calls Prod FullCode. Another routine is available to update Attendees’ Company references where they are not correctly linked. It transfers the linked Contact’s Company Code where applicable. To run it, simply construct a one line macro which calls Attend Contacts.


