Display files are DDS files that enable us to create AS/400 menus and screens to interact with the user. Display files can have several records. Each record defines part of the screen's appearance. These records may or may not overlap each other.
顯示文件是一些幫助我們創建和用戶進行交互的AS400菜單和屏幕界面的DDS文件。顯示文件能夠包含多個紀錄,每個記錄定義了屏幕界面的一部分。這些記錄或者相互覆蓋。
The SDA application allows us to “draw” what should show up on the screen and creates the DDS code from our “drawing”. Next we'll create a screen with DDS and afterward we'll look at some code excerpts, because sometimes it's easier to alter the screen through its code.
SDA程序允許我們在屏幕上“畫草稿”,它會根據我們所畫的“草稿”生成相應的DDS代碼。下面,我們將要創建利用DDS創建一個屏幕界面,然后查看這些代碼的片斷,因為,有些時候,利用代碼來修改界面還是比較容易些。
In this chapter ,we'll create a screen to show a clients data.
在這一章,我們將創建一個顯示客戶數據的界面。
To open SDA type STRSDA on the system prompt. This screen should appear:
在系統命令行輸入STRDA就可以打開SDA程序了,如下圖顯示:

Choose option 1 and type the options as you see them on the image below. Source file is the file where the code will be stored. Member is the name of member we're creating.
選擇1,然后輸入相關的選項,如下圖,Source file就是代碼保存的文件了,在Member輸入我們想要創建的成員(Member)。

Create file 創建文件
Press Enter. A new screen appears. Add a new record, named TOP, typing what you see on the image bellow.
按下回車鍵,然后我們添加記錄,命名為Top,如下圖

Now specify the record type, in this case it's RECORD:
接著我們輸入記錄類型,在這個例子中我們輸入Record
After the Enter an empty screen appears. In this screen you can “draw” the top record. Add the content you see on the image bellow.
按下回車,現在我們就可以“草繪” top記錄,添加內容了,如下圖:
When you type a string you should place it between apostrophes. If you don't each word will be handled like a different field. Placing the apostrophes allows you to manipulate all the words as a single field.
當你想輸入一個字符串的時候,請問打上單引號,假如你不這樣做的話,系統會把他們當作分開的不同字符串。
The *USER function shows the username on the screen. There are other functions that retrieve information from the system: *DATE (shows the system current date), *TIME(shows the system current time), *SYSNAME (shows the system name).
*USER用來在屏幕上顯示用戶名
*DATE用來在屏幕上顯示系統當前日期。
*TIME 用來在屏幕上顯示系統的當前時間。
*SYSNAME 用來在屏幕上顯示系統名稱。

After typing what you see on the image press Enter. Always check what you've done before pressing Enter, because after that you can only alter the screen by manipulating its code. You can also exit the record editing without saving your work, but then you'll lose all you've done since you last opened the record for editing.
按照上圖輸入完成后按下回車,就可以看到下圖了,請在按下回車之前仔細檢查,因為按下回車之后,只能用代碼進行修改了,當然,你也可以退出這條記錄而不保存,但是你就會丟失這些工作成果。
Moving a field 移動字段
You can move a field to the right placing “>” characters to the right of the field. The number of > you type will be the number of columns the field will move. To move the field to the left place < signs on the left side of the field.
你可以通過在字段右邊的輸入〉來使字段向后移動,你輸入〉符號的數量就是字段向右移動的位移量,向左是同樣的道理。

Centering a field 字段居中
To center a field on the screen place an 'ac' at the left of the field and the 'c' must be overlapping the first character of the field. Then press Enter.
Press F3 to finish editing this record. Choose option 1 to save your work:
要是想將字段居中,你可以在字段的左邊輸入ac,c必須覆蓋字段字段的第一個字符,然后按下回車,按下F3結束你對字段的編輯,選擇1保存你的工作成果。

Create another record named BOTTOM, the same way you've created the TOP record.
現在我們創建另外一個記錄叫做Bottom,方法是跟創建TOP字段是一樣的。
When you open the new record for editing press F9. This menu will appear:
當你打開按下F9對新的記錄,我們可以看見菜單顯示出來了

So that you don't overlap the records you can choose to visualize other records in the menu. You can see that the status of the BOTTOM record is “In Use” which means it is the one currently being edited. You can select at most 3 records to visualize. To do so place numbers 1 to 3 on the records you want. Select the TOP record and press Enter.
為了不要覆蓋你的其他記錄,你可以選擇在菜單中對其他記錄可視化,你可以發現Bottom記錄處于正在使用“In Use”狀態,意味著這正是我們正在編輯的記錄,你可以選擇最到3條記錄進行可視化,將1,2,3 放在你想可視化的記錄上面,然后按回車

The names of the selected fields appear on the bottom of the screen. Don't forget you are only “drawing” on the record in use. The other records only help you place your elements on the right place.
可以看到,你所選的字段顯示在屏幕的底部了,但是你不要忘記了,你只能“草繪”那個正在使用(“In Use”)的記錄,其它記錄只能輔佐那個正在使用的字段放置合適的位置而已。
“Draw” something similar to what you see in the next image. Use the underscore to make the line.
像下圖那樣“草繪”我們的需要的界面,我們使用下劃線描述出一條直線來

Changing field proprieties修改字段屬性
We're going to edit the proprieties of the “F3=Exit” field. Place an '*' at the left of the field and press Enter:
我們現在修改“F3=Exit” 字段的屬性,在這個字段的左邊輸入*, 然后按下回車。

This screen appears. Place an 'Y' in the Colors option. We're going to change the color of the characters.

Place an 1 in the Blue field:

Select blue color 選擇藍色
Press Enter until you're back in the editing screen. The field is now blue. Exit the editing screen (F3) and save your work.
按回車返回,直至你返回編輯界面,現在可以看到字段已經變成藍色了,按F3退出編輯界面然后保存你的工作成果。
Create a new record, MIDDLE, the same way you've created the previous records.
創建一個新的記錄,MIDDLE,方法跟你之前的事一樣的
Press F9 to visualize the records you already created:
按F9可視化你剛剛創建的記錄

Draw what you can see in the following image. Press Enter when you're done.

Add fields
添加字段
Using table records
使用表記錄
We're going to select the fields from the Clients table to show them on the screen. Press F10. On that menu select the Database File Clients for output (option 3). You can also select fields for input or input/output choosing one of the other options. You should write this on the menu and press Enter:
現在我們將要在客戶表中選擇我們想要的字段,將他們顯示在界面上面,按下F10,現在第3項(select the Database File Clients for output),你也可以為其它的選項,選擇字段作為輸出和輸入。

Select the table 選擇表
On the bottom of the screen there's a message with all the Client's field names preceded by a number. To use a field on the screen you should write its correspondent number preceded with an '&'. You can see it in the next image. Be careful, because if you write a number and press Enter the order of the list on the bottom will change.
在下圖中,你可以看到一條信息顯示在最下面,顯示了客戶表的所有字段和字面名字前面附帶著號碼,要將這些字段顯示在界面的,你需要將相關的字段的號碼寫在屏幕界面上,前邊帶上一個‘&’的符號,如下圖,

The final result: 最后結果

Exit the record editing. We now need to make a few adjustments to the file options.
推出記錄編輯,我們需要對文件選項進行一些修改
Record level options (overlay) 記錄層面選項(覆蓋)
Choose option 8 to the TOP record: 在Top記錄選擇選項8

Change overlay option 修改覆蓋選項
Select option Overlay Keywords: 選擇覆蓋關鍵字

Change overlay option step 2 修改覆蓋選項第二步
Place an Y at the option Overlay without erasing. This option allows to display this record on the screen together with the others. Press Enter until you reach the menu with the record listing. Activate this option on the other records.
在選項(Overlay without erasing)的地方輸入Y,這個選項允許你在屏幕界面中同時顯示其他的記錄。一路回車直至你看到記錄列表,在其他界面中激活這個選項

Change overlay option step 3
修改覆蓋屬性步驟3
File level options (indicators) 文件層面的選項(指示器)
We need to declare the indicator 03 (so that “F3=Exit” works) at the file level. On the menu with the record listing press F14 (F13=shift+F1; F14=shift+F2; F15=shift+F3, etc.). On the following screen choose the option Indicator Keywords.
要實現“F3=Exit”的功能,我們需要需要在文件的層面聲明指示器03,在字段列表的菜單中我們輸入F14 (F13=shift+F1; F14=shift+F2; F15=shift+F3, etc.).然后,我們選擇指示器選項關鍵字,如下圖

Insert the data you see on the image below:按照下圖輸入

Press Enter until you've reached the starting menu. Press F3 and save the file.
一路回車直至看到開始菜單,按F3保存文件。
Display Files DDS code 顯示DDS文件的代碼
You can check out the code from this display at QDDSSRC, the member is SHW_CLI. At the beginning of the file should be something like this:
你可以查看上面步驟產生的DDS代碼,位置在QDDSSRC,成員名字是SHW_CLI,在文件的開頭我們可以看到這樣兩行:
A DSPSIZ(24 80 *DS3)
A CF03(03 'Exit')
These are the file-level options. You should add a line to this area that later will allow you to rename the indicators used. Add this line after the DSPSIZ line:
這是文件層面的選項,你遲些可以在這里增加一行,它允許你重命名這個已經用了的指示器,在DSPSIZ后面添加一行,如下
A INDARA
You should also have some lines like these: 你也可以添加幾行像下面的:
A R TOP
A OVERLAY
A 1 65USER
A 3 27'Client Details:'
In these four lines are the definitions to the TOP record. Notice the OVERLAY option we had defined in SDA. The keyword USER is placed on the 1st line, column 65.
上面四行是關于TOP 記錄的定義,要注意的是OVERLAY 選項是我們在SDA中定義的,關鍵字USER被放在第一行,第65列。
Look at this line from MIDDLE record: 現在我們看看MIDDLE的記錄
A ID_CLI R O 8 23REFFLD(CLIENTS/ID_CLI DEMO/CLIENTS)
Here you have a reference to the ID_CLI field on the CLIENTS table and this reference is positioned at line 8 column 23, an can only be accessed for reading (O).
這里你定義了一個引用,指向CLIENTS表的ID_CL字段,這個字段的位置在第8行,第23列,是一個只讀的字段。
Compile the file (option 14) after you've closed the member.
關閉了這個成員之后,你可以按F14編譯這個文件。
Executing display files 執行顯示文件
To run the screen you must create an RPGLE member which will handle all the possible events (pressing F3 for example). Check out the file QRPGLESRC.SHW_CLI to see how this member should be defined. Create a file like QRPGLESRC.SHW_CLI and run it. The result should be something like this:
要運行這個界面,你必須創建一個RPGLE成員,來處理所有可能的事件(例如按下F3),打開文件QRPGLESRC.SHW_CLI,看看我們英文怎么定義這個成員,創建一個像QRPGLESRC.SHW_CLI文件,然后我們運行,結果如下圖,

Execute display file 1
If you press Enter: