Screens: @Layout and Screen
A Screen is an interactive 5250 screen: it defines its layout (@Layout) and reacts to user events (@Source).
1. Minimal structure
@Properties {
Type : Screen
Name : SFORM01
Description : "Sample screen"
Path : Screens
}
@References {
Tables = ["../tables/TLADD50.warp"]
}
@Variables {
Global {
Username char(10)
MyDate Date
}
}
@Parameters {
}
@Layout {
@Label(1,2,&Username)
@Label(1,70,&MyDate)
@Input("txtRequestNo", 3, 1, "Request No.: ", &RequestNo, true)
}
@Source {
Event Init
&Username = UserId()
&MyDate = Today()
EndEvent
}
Unlike a Program, a Screen doesn’t have its own @Structure — it only references tables to read/write.
2. @Layout controls
Label(x, y, text): static text/variable.x,y = 1,1(exact corner) is forbidden — DDS rejects it.Input("Name", x, y, text, &Variable, enabled): editable field."Name"is whatCurrentInput()returns when the cursor lands there.enabledis optional (defaulttrue): a literal,&Variable, or a function returningnumber.DataGridView("Name", x, y, rows)[...]: grid — see DataGridView.
Control names can be prefixed with @ (@Label, @Input) or not — it’s purely stylistic, same meaning.
3. Standard events
| Event | When it fires |
|---|---|
Init | Once, before the first display. |
Load | Once, before the first display — typically fills the DataGridView with LoadRow(). |
Enter | On pressing Enter (with no function key active). |
Refresh | On pressing F5, if declared in the project’s @FunctionKeys. |
Close | Fixed to F3 — always runs and closes the screen, no declaration needed. |
@Source {
Event Init
&Username = UserId()
EndEvent
Event Load
For Each In LADD50 Index LADD5010
Where SPT25COUNTRY = &nCountry
&cState = ADSTS50
LoadRow()
EndFor
EndEvent
Event Enter
&Control = CurrentInput()
Message("Active control: " + &Control, Info)
EndEvent
}
4. Custom function keys
Besides the standard events, you can attach an event to any F1-F24 key (F13-F24 via Shift):
@Source {
Event 'FindCustomer' 4
Message("F4 was pressed", Info)
EndEvent
}
The label shown in the attention line is configured in the project’s .warpcfg @FunctionKeys — see Project.
5. Messages to the user
Message("Rows found: " + String(&nRows, 5), Info)
Error (red), Warning (yellow), Info (normal color). Shown on the next refresh and cleared after one cycle.
6. Next step
If the screen needs to show a list of rows with selection/pagination, see DataGridView.