If you have a date field on an image and you're tired of having to enter all parts of the date you can use the following code to default the date to today. Put this in the set SET RUN-TIME DEFAULTS Event Point:
IF --- INTERACTIVE PHASE = DATA ADDITION AND APP DATEFLD = T SET DATE APP DATEFLDThis will default in the current time stamp for you and you can just change the parts that you need. If the date field is part of a key, you should change the test for DATA ADDITION to KEY ENTRY.
Designer Sort Order
We have Designer Record Selection, where we, as designers, can specify certain criteria that the user can't override. We don't have the same capability for Sort Order. Consider an example where we *must* sort on certain fields last, but we want the user to be able to choose the first fields to sort on. We can specify that the fields must be included in the sort, be we can't specify that they are to be the last 2 fields. Or can we? Consider the following code that was inserted in the End of Process (Query Setup) Event Point:
BEG READ --- QSORT HOLD 0 KEY IS QSORT KEY SET --- A = --- QSORT SNO SET --- TEMP 4 = --- QSORT QRY AP SET --- TEMP 30 = --- QSORT QRY NAM END READ --- QSORT * SET --- QSORT QRY AP = --- TEMP 4 SET --- QSORT QRY NAM = --- TEMP 30 SET --- QSORT PAD = SET --- QSORT SNO = --- A COMPUTE --- QSORT SNO + 1 SET --- QSORT FLD AP = PSO SET --- QSORT FLD NAM = ORDERAUD AUD FILE FLAG SET --- QSORT ALIGN 1 = SET --- QSORT FLD OCC = 000 SET --- QSORT ORD = + SET --- QSORT REQ = N SET --- QSORT NEW PG = N SET --- QSORT SUBH = N SET --- QSORT CONT MSG = N SET --- QSORT SUBT = N SET --- QSORT SUBT NEW PG = N SET --- QSORT AVE = N SET --- QSORT MIN = N SET --- QSORT MAX = N SET --- QSORT ORD ED = N SET --- QSORT NEW PG ED = Y SET --- QSORT SUBH ED = N SET --- QSORT CONT MSG ED = N SET --- QSORT SUBT ED = N SET --- QSORT SUBT NEW PG ED = Y SET --- QSORT AVE ED = N SET --- QSORT MIN ED = N SET --- QSORT MIN ED = N SET --- QSORT MAX ED = N SET --- QSORT ACTV = Y SET --- QSORT MOD = N SET --- QSORT ALIGN 2 = WRITE --- QSORT FAIL 0 COMPUTE --- QSORT SNO + 1 SET --- QSORT FLD NAM = ORDERAUD AUD TRANS TYP WRITE --- QSORT FAIL 0The fields we wanted to sort on are the ORDERAUD AUD FILE FLAG and ORDERAUD AUD TRANS TYP, and they had to be the last 2 fields in the sort order. We did not include them in the sort display, so the user did not have a chance to select them or disturb the sort order, although they could sort on other fields if they wanted. Once the Sort Setup step was complete, this code would execute. The first step is to read the QSORT file to get the last sequence number, and while we are at it, save the query application and name. Once all the records are read, we can add 2 records for the fields we want to sort on, incrementing the sequence number for each field. Notice that there are several interesting fields in QSORT, such as QSORT AVE, MIN, MAX. We don't recommend setting these to a "Y"...:-)
Also note that if there was more than one Query in the current job, it may also be in the QSORT file, and the necessary code would have to be added to only modify the records for the desired Query.
The APPX environment has an unique variable share class, namely DETACHED. You can create work fields, memory files or disk files with this scope, and information loaded into these files/fields will remain there for the duration of the users session, regardless of what processes they may run.
One possible use for this is to load some user defaults once when they start APPX. These fields would then be available to every APPX process without having to refer to a file. This is in contrast to the usual approach of storing them in a file, and reading that file every time you need that information.
Another use would be to keep track of whether the user has invoked Direct Process 1 already. If you are using DP 1 at your installation, it can be easy for your users to forget they have already invoked DP 1, and invoke it again to run another process, thus creating a process family in memory that consumes resources unnecessarily. One approach in dealing with this would be to create a work field with a share class of DETACHED. When they invoke DP 1, that process should increment the work field, and when they leave DP 1 via END or CANCEL, it should decrement the work field. If the work field is already non zero when DP 1 is started, that tells you that they already have one process suspended via DP 1 and you can take appropriate action.
Determining the current KeyPath
In an Input process, there are times when it would be useful to know which KeyPath the user has selected. The PDF --- ENTRY SELECTED PATH will tell you this. It contains a 1 if they are using the primary key, a 2 for the first alternate key, etc. This can also be used as an Index into the PDF --- ENTRY PATH DESC (17 occurrences) to get an alpha description of the current KeyPath. This can be useful when you have an alternate key whose fields are not on the image. By testing this PDF, you can display an alternate image that does contain the alternate key fields.
Warning: APPX adds the following comment: It is a coincidence that --- ENTRY SELECTED PATH is set to the selected keypath. This is undocumented behaviour and will change in a future release.
If you are running Release 4.1 or higher, the PDF --- ACCESS PATH will contain the field name of the field that is currently being used as the access path.
Ever wish APPX had a looping construct that allowed something like 'DO
LABEL :TRY AGAIN SET DATE XXX TRANS DATE WRITE XXX TRANS F GOTO :TRY AGAINUsing a BEG LOOP/END LOOP, we could write it as follows:
BEG LOOP WI = 0 TO 1 STEP 000 SET DATE XXX TRANS DATE WRITE XXX TRANS F END LOOP WIThe Step value for WI in the BEG LOOP command is zero, so the loop will never finish on its own, but notice that we only execute the END LOOP command if the WRITE fails. If the WRITE is successful, APPX will simply drop thru to the next statement after the END LOOP. Voila, we have a DO
Drawing lines (4.2 Only)
Drawing lines is not directly supported, but another way to think of a line is a very narrow (or tall) box. If you draw a one row box, and then set the Height to 90, you will get a horizontal line. You can use the fill colour to set the colour of the line.
To get a vertical line, just draw a box one column wide and several rows tall, and set the width to 90. Note that because of aspect ratios, this will appear thinner than the horizontal line. You can adjust the height & width until the lines look the same, if required.
'Drill Down' Inquiries
Ever wanted to make your simple Inquiry processes interactive? Ever wondered what the 'PRINT FILE BROWSABLE' flag could possibly be used for? This page shows you how to provide a 'drill down' capability to your inquiry process.
Dynamic Screen Size/Position
A little known trick in APPX is having APPX automatically centre your screen for you, or have it dynamically size a scrolling window based on the number of lines on the display. To have APPX centre a Input frame, simply set the ROW and COLUMN to zero (you must enter a zero, you can't leave it blank). To centre it horizontally only, just set the ROW to zero, and to centre it vertically, just set the COLUMN to zero.
Dynamic sizing of a scrolling window is best illustrated by an example:
Position Size- Dspl Scroll Mult Seq No Descriptive Row Col Row Col Only? Type Box? Img? ======= =========== ======== ======= ===== ====== ==== ====== 50 2 2 -1 78 Y NONE Y N 100 Header 2 2 3 78 Y NONE N N 150 Footer -2 2 2 78 Y NONE N N 200 Detail 5 2 -2 78 N DOWN N NFrame 50 simply draws a box around the entire screen. The Row Size of '-1' tells APPX that this frame is one line less than the number of rows on the screen. Frame 100 is an ordinary header frame that will appear in the top portion of the screen, position & Size are specified normally. Frame 150 is a 'footer' frame that will 'float' depending on the number of rows on the screen. Since the footer frame is 2 rows in size (and therefore needs 2 rows to display), we set the Row Position to '-2' to tell APPX to put this frame 2 rows from the bottom of the display. Finally, Frame 200 is our detail frame that actually contains the data. Since our footer frame occupies the last 2 rows, we set the size to '-2' to tell APPX this frame extends from below our header frame to 2 rows from the bottom of the display.
How do you run APPX with other than the default 21 rows? If you are using the Presentation Manager, you can't. If you are using the Java Client, you can set the rows and columns by setting '-rows=' and '-cols=' on the command line. If you are using character based Unix, set your terminal emulation software to the number of rows you want, then run APPX normally.
Designing PDF Forms
Occasionally a user will create a mock up of a form they want printed in Appx. They'll use Excel, or Word, or some similar program and give you the printout. The challenge now is to try to determine what font size and line spacing they used so we can define a similar PDF form in Appx. Luckily Appx gives us some help with this. First, print several copies of the form the user created. Next, define a form in Appx System Administration, taking your best guess at the character and line spacing and checking the box 'Print Grid' at the bottom of the screen.
Now feed the sample form into the printer and print on top of it using your new APPX form. You need to print some data on the form so you might have to create a simple output that just prints one line. Since the 'Print Grid' box is checked, Appx will print your single line and a row and column grid that shows you the character and row spacing for the current form definition. Since you printed the grid on top of their mock up, you can see how well it matches. Now you can adjust the form definition and try another test print until you get as close as you can to the spacing the user has on their mock up.
The grid output will also include a few extra pages at the end with some additional measurements,
as well as an explanation of setting APPX_GRID_STYLE for more control over what prints on the
grid. The grid will also make it easier for you to design your output, as you'll be able to count
rows & columns to position the data precisely.
For additional information, contact email@example.com
[back to top]