Added new basic samples · KcsDev1982/sunbelt-plb-samples@07472b9 · GitHub
Skip to content

Commit 07472b9

Browse files
committed
Added new basic samples
Added samples that cover basic PL/B topics, such as disk I/O, and various instructions.
1 parent b06f366 commit 07472b9

29 files changed

Lines changed: 1313 additions & 16081 deletions

README.md

Lines changed: 2 additions & 2 deletions

basicsamples/afile1.pls

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
*====================================================
2+
. AAM Sample Program
3+
. Demonstrates creation, writing, and reading of an AAM file
4+
*====================================================
5+
6+
Customer AFILE
7+
CustID DIM 10
8+
Name DIM 30
9+
City DIM 20
10+
Balance FORM 7.2
11+
12+
Key DIM 33
13+
14+
CALL Main
15+
STOP
16+
17+
*----------------------------------------------------
18+
. Main Routine
19+
*----------------------------------------------------
20+
Main LFUNCTION
21+
ENTRY
22+
23+
*--- Create or open the file
24+
PREPARE Customer, "customer.dat","customer.aam","1-10,11-40,41-60","70"
25+
26+
*--- Add some customer records
27+
MOVE "C001" TO CustID
28+
MOVE "John Smith" TO Name
29+
MOVE "Dallas" TO City
30+
MOVE 125.75 TO Balance
31+
WRITE Customer;CustID,Name,City,Balance
32+
33+
MOVE "C002" TO CustID
34+
MOVE "Mary Smith" TO Name
35+
MOVE "Houston" TO City
36+
MOVE 89.20 TO Balance
37+
WRITE Customer;CustID,Name,City,Balance
38+
39+
CLOSE Customer
40+
41+
*--- Read generic
42+
OPEN Customer, "customer.aam"
43+
DISPLAY *N,"Customer Records:",*N
44+
MOVE "02FSmith" TO Key
45+
READ Customer,Key;CustID,Name,City,Balance
46+
LoopRD IF OVER
47+
GOTO EndRead
48+
ENDIF
49+
50+
DISPLAY CustID, " - ", Name, " - ", City, " - ", Balance
51+
READKG Customer;CustID,Name,City,Balance
52+
GOTO LoopRD
53+
EndRead
54+
55+
*--- Read a specific record by key
56+
MOVE "01XC002 " TO Key
57+
READ Customer,Key;CustID,Name,City,Balance
58+
IF NOT OVER
59+
DISPLAY *N,*N,"Record Found:",*N
60+
DISPLAY CustID," - ",Name," - ",City," - ",Balance
61+
ELSE
62+
DISPLAY *N,"Record not found."
63+
ENDIF
64+
65+
*--- Done
66+
CLOSE Customer
67+
PAUSE "5"
68+
FUNCTIONEND

basicsamples/basicsamples.prj

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<SunIDE_Project_File Version="10.0">
3+
<ActiveProfile>basicsamples</ActiveProfile>
4+
<ProjectTitle>basicsamples</ProjectTitle>
5+
<SelectedProgram>switch2.pls</SelectedProgram>
6+
<Profiles>
7+
<Name>basicsamples</Name>
8+
<Properties>
9+
<SourceFolder>C:\Sunbelt\sunbelt-plb-samples\basicsamples\</SourceFolder>
10+
<Compiler/>
11+
<CompilerIni/>
12+
<CompilerOptions>-WS#1</CompilerOptions>
13+
<MinimizeCompiler>1</MinimizeCompiler>
14+
<BookmarkErrors>0</BookmarkErrors>
15+
<ShowCompilerCmd>1</ShowCompilerCmd>
16+
<MaxErrors>99</MaxErrors>
17+
<SymbolFile>0</SymbolFile>
18+
<OpenEnded>1</OpenEnded>
19+
<CrossReference>0</CrossReference>
20+
<MetadataMode>2</MetadataMode>
21+
<MetadataFolder/>
22+
<Graphics>0</Graphics>
23+
<NoDuplicate>0</NoDuplicate>
24+
<EncryptSymbols>0</EncryptSymbols>
25+
<FlagConflicts>0</FlagConflicts>
26+
<AbortError>0</AbortError>
27+
<PauseError>0</PauseError>
28+
<PauseSeconds>2</PauseSeconds>
29+
<MultipleTraps>0</MultipleTraps>
30+
<ReadMode>0</ReadMode>
31+
<Restricted>0</Restricted>
32+
<OutputExt/>
33+
<OutputFolder/>
34+
<OutputMode>1</OutputMode>
35+
<WorkFolder/>
36+
<CaseSensitive>0</CaseSensitive>
37+
<CommentDelims/>
38+
<SourceExt/>
39+
<CompatMode>1</CompatMode>
40+
<ListMode>1</ListMode>
41+
<ListFolder/>
42+
<DisableWarnings>0</DisableWarnings>
43+
<GeneratedCode>0</GeneratedCode>
44+
<NoTimestamp>0</NoTimestamp>
45+
<ListErrorDelete>0</ListErrorDelete>
46+
<NoOutput>1</NoOutput>
47+
<ErrorsOnly>0</ErrorsOnly>
48+
<AllSource>0</AllSource>
49+
<ExpandedMacros>0</ExpandedMacros>
50+
<ListOff>0</ListOff>
51+
<FalseIf>0</FalseIf>
52+
<SpoolFile>0</SpoolFile>
53+
<SpoolAppend>0</SpoolAppend>
54+
<IniFile/>
55+
<WorkingDirectory/>
56+
<HideMain>0</HideMain>
57+
<GlobalData>64</GlobalData>
58+
<VirtualMemory>20</VirtualMemory>
59+
<Arguments/>
60+
<DebugLog>1</DebugLog>
61+
<Debugger>1</Debugger>
62+
<DebugProcess>0</DebugProcess>
63+
<DebugBreakFirst>1</DebugBreakFirst>
64+
<DebugHost/>
65+
<DebugPort/>
66+
<PreBuildEnabled>0</PreBuildEnabled>
67+
<PreBuildCommands/>
68+
<PostBuildEnabled>0</PostBuildEnabled>
69+
<PostBuildCommands/>
70+
<FTPUpload>0</FTPUpload>
71+
<FTPDebug>0</FTPDebug>
72+
<FTPAccount/>
73+
<FTPFolder/>
74+
<EnableBackups>1</EnableBackups>
75+
<MaxBackups>10</MaxBackups>
76+
<BackupDir>.\Backups\</BackupDir>
77+
<GitEnabled>0</GitEnabled>
78+
<GitFolder/>
79+
<GitBranch/>
80+
<GitUserName/>
81+
<GitEmail/>
82+
<GitRemote/>
83+
</Properties>
84+
</Profiles>
85+
<Source Name="lfunc1.pls"/>
86+
<Source Name="filelist1.pls"/>
87+
<Source Name="filelist2.pls"/>
88+
<Source Name="squeeeze.pls"/>
89+
<Source Name="findword.pls"/>
90+
<Source Name="explode.pls"/>
91+
<Source Name="switch1.pls"/>
92+
<Source Name="switch2.pls"/>
93+
<Source Name="file1.pls"/>
94+
<Source Name="afile1.pls"/>
95+
<Source Name="ifile1.pls"/>
96+
<Source Name="json1.pls"/>
97+
<Source Name="like1.pls"/>
98+
<Source Name="datetime1.pls"/>
99+
<Source Name="json2.pls"/>
100+
<Source Name="datetime2.pls"/>
101+
<Source Name="file2.pls"/>
102+
<Source Name="file3.pls"/>
103+
<Source Name="keyin1.pls"/>
104+
<Source Name="button1.pls"/>
105+
</SunIDE_Project_File>

basicsamples/button1.pls

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
*---------------------------------------------------------------*
2+
. Example: BUTTON Object Usage in Sunbelt PL/B
3+
. This example creates a window with an Exit button.
4+
*---------------------------------------------------------------*
5+
6+
Button1 BUTTON
7+
UserAction FORM 4
8+
9+
*---------------------------------------------------------------*
10+
. Create a window and add a button control
11+
*---------------------------------------------------------------*
12+
CREATE Button1=5:8:5:8,"Exit"
13+
14+
*---------------------------------------------------------------*
15+
. Activate button and make the window visible
16+
*---------------------------------------------------------------*
17+
ACTIVATE Button1,Exit,UserAction
18+
19+
20+
*---------------------------------------------------------------*
21+
. Wait for user events
22+
*---------------------------------------------------------------*
23+
MainLoop
24+
LOOP
25+
WAITEVENT
26+
REPEAT
27+
28+
*---------------------------------------------------------------*
29+
. Button click event handler
30+
*---------------------------------------------------------------*
31+
Exit
32+
STOP

basicsamples/datetime1.pls

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
*------------------------------------------------------------
2+
. DATETIME methods demo (SetToNow, SetAsString, Adjust, Compare, GetAsString)
3+
*------------------------------------------------------------
4+
5+
*-----------------------------
6+
* Data Definitions
7+
*-----------------------------
8+
NOW DATETIME
9+
PARSED DATETIME
10+
WORK DATETIME
11+
12+
RET FORM 2
13+
CMP FORM 2
14+
15+
VAL DIM 30 // input value to parse
16+
OUT_ISO DIM 40 // ISO-8601 UTC
17+
OUT_LOC DIM 40 // Local time, custom format
18+
OUT_PAR DIM 40 // Parsed value (formatted)
19+
OUT_ADJ DIM 40 // Adjusted parsed value (formatted)
20+
21+
ADJ1 DIM 8 // e.g., +3D (add 3 days)
22+
ADJ2 DIM 8 // e.g., -2H (subtract 2 hours)
23+
24+
CALL Main
25+
STOP
26+
27+
*-----------------------------
28+
* Main routine
29+
*-----------------------------
30+
Main LFUNCTION
31+
ENTRY
32+
33+
* Set NOW to current UTC, then format as ISO-8601
34+
MOVE "0" TO RET
35+
NOW.SetToNow GIVING RET USING *LocalTime=0
36+
NOW.GetAsString GIVING OUT_ISO USING *Format="%Y-%m-%dT%H:%M:%f%Z"
37+
38+
* Also show NOW in Local Time with a custom format
39+
NOW.GetAsString GIVING OUT_LOC USING *Format="%Y-%m-%d %H:%M:%S",*LocalTime=1
40+
41+
* Parse a specific date/time string into PARSED
42+
MOVE "2025-12-25 14:30:00" TO VAL
43+
PARSED.SetAsString GIVING RET USING *Value=VAL
44+
PARSED.GetAsString GIVING OUT_PAR USING *Format="%Y-%m-%d %H:%M:%S",*LocalTime=1
45+
46+
* Make a working copy and apply adjustments
47+
WORK.SetToDateTime GIVING RET USING *DateTime=PARSED
48+
49+
* Example adjustments: add 3 days, then subtract 2 hours
50+
MOVE "+3D" TO ADJ1
51+
WORK.Adjust GIVING RET USING *Value=ADJ1
52+
53+
MOVE "-2H" TO ADJ2
54+
WORK.Adjust GIVING RET USING *Value=ADJ2
55+
56+
WORK.GetAsString GIVING OUT_ADJ USING *Format="%Y-%m-%d %H:%M:%S",*LocalTime=1
57+
58+
* Compare NOW to PARSED (CMP < 0: NOW < PARSED, CMP = 0: equal, CMP > 0: NOW > PARSED)
59+
MOVE "0" TO CMP
60+
NOW.Compare GIVING CMP USING *DateTime=PARSED
61+
62+
*-----------------------------
63+
* Display results
64+
*-----------------------------
65+
DISPLAY *HD,*N,"DATETIME Methods Demo",*N
66+
DISPLAY *N,"NOW (UTC ISO): ",OUT_ISO
67+
DISPLAY *N,"NOW (Local): ",OUT_LOC
68+
DISPLAY *N,"PARSED (Local): ",OUT_PAR
69+
DISPLAY *N,"ADJUSTED (Local): ",OUT_ADJ
70+
71+
IF (CMP<0)
72+
DISPLAY *N,"Compare: NOW is earlier than PARSED",*W2
73+
ELSEIF (CMP=0)
74+
DISPLAY *N,"Compare: NOW equals PARSED",*W2
75+
ELSE
76+
DISPLAY *N,"Compare: NOW is later than PARSED",*W2
77+
ENDIF
78+
79+
FUNCTIONEND

basicsamples/datetime2.pls

Lines changed: 79 additions & 0 deletions

0 commit comments

Comments
 (0)