Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
sunbelt-plb-samples/legacy_demo/winapi.pls at main · KcsDev1982/sunbelt-plb-samples · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
KcsDev1982
/
sunbelt-plb-samples
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
5
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
main
Breadcrumbs
sunbelt-plb-samples
/
legacy_demo
/
winapi.pls
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
192 lines (188 loc) · 6.91 KB
main
Breadcrumbs
sunbelt-plb-samples
/
legacy_demo
/
winapi.pls
Copy path
Top
File metadata and controls
Code
Blame
192 lines (188 loc) · 6.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
*............................................................................
.
.Example Program: WINAPI.PLS
.
.This sample programs demonstrates the use of the WINAPI instruction to
. to search for files using a user specified mask.
.
. Copyright @ 1997, Sunbelt Computer Systems, Inc.
. All Rights Reserved.
.............................................................................
.
. Revision History
.
. 10-6-98 JSS: Test System Info for GUI environment, use text based code
. if not GUI.
. 10-6-98 JSS: FindFirst API needed to handle failure to find a match.
*............................................................................
.
. Include PROFILE declarations
.
INCLUDE PROFILE.INC
*
. FileData defines a DIM variable which will receive the names and
. properities of files which are found. The FileData is a file data
. structure used within Windows.
.
FileData DIM 400 ;Name is at offset 44 + 260
FileAttr INTEGER 4 ;File Attributes
Extra DIM 40 ;
LongName DIM 260 ;
ShortName DIM 14 ;
.
Name DIM 270
Ans DIM 1
SmName DIM 80
Term INIT 0x0
.
FHANDLE INTEGER 4 ;File Handle
RESULT1 INTEGER 1 ;Boolean result
RESULT FORM 12
ST1 STATTEXT
ET1 EDITTEXT
ST2 STATTEXT
B1 BUTTON
BGC COLOR
NOTE DIM 70
LINE FORM " 3"
N10 FORM 10
MinusOne FORM "4294967295" ; =0xffffffff
*............................................................................
CREATE BGC=*LTGRAY
.
.Retrieve the File Specification from the User
.
CREATE ST1=2:2:1:30,"Enter the File Specification: ":
"FIXED(BOLD)",ALIGNMENT=3
CREATE ET1=2:2:31:70,BGCOLOR=BGC
CREATE ST2=3:3:5:75,"","SYSTEM(10)"
CREATE B1=2:2:72:78,"OK"
ACTIVATE ST1
ACTIVATE ST2
ACTIVATE ET1
ACTIVATE B1,ET1CODE,RESULT
SETFOCUS ET1
EVENTREG ET1,11,ET1CODE
. ACTIVATE ET1,ET1CODE,RESULT
.
*
LOOP
WAITEVENT
REPEAT
*
. Since the function 'FindFirstFileA' defines that string parameters
. must be terminated with a binary zero, we are appending a binary
. zero to the name keyed by the user.
.
ET1CODE
GETITEM ET1,0,SmName
PACK Name USING SmName,Term
ALERT NOTE,SmName,N10
*
. Execute the Windows Api function to find the first occurance of
. the file specification supplied by the user.
.
WINAPI FindFirst GIVING FHANDLE USING NAME,FileData
*
. If the return value identified as FHANDLE is zero or -1, then the file
. was not found. In this case, this program simply exits.
.
MOVE FHANDLE,N10
IF ( FHANDLE = MinusOne )
PACK NOTE WITH "Name not found...",N10
ALERT STOP,NOTE,RESULT
STOP
ENDIF
*
. If we get to this point, a file was found and the FHANDLE variable
. contains a file handle to be used in the 'FindNextFile' call later.
. The variable 'FileData' was modified to contain the names and properties
. of the file which was found. Note that we are using an UNPACK to
. get the individual members of the 'FileData' structure.
.
UNPACK FileData INTO FileAttr: ;File attributes
Extra: ;Not used here
LongName: ;Long file name found
ShortName ;Short file name
*
. The FileAttr value found in the FileData structure identifies the
. type of file found.
.
CALL ShowName ;Identify file type
*
. Now we want to loop and find all subsequent instances of the file name using
. the FindNext WINAPI function.
.
LOOP
*
. Get the next file meeting the file name specifications given.
. Note: The FindNext PROFILE function uses the File Handle provided
. by the FindFirst PROFILE function.
.
WINAPI FindNext GIVING RESULT1 USING FHANDLE,FileData
.
. When the returned value found in RESULT1 is zero, then there are no more
. files found using the file name specification.
.
UNTIL (RESULT1 = 0)
*
. At this point we have found another file and we will determine the
. file type. We first unpack the FileData structure into the appropriate
. members to be used.
.
UNPACK FileData INTO FileAttr,Extra,LongName,ShortName
*
. The FileAttr value found in the FileData structure identifies the
. type of file found.
.
CALL ShowName ;Identify File Type
*
. Continue the loop looking for the next file
.
REPEAT
*
. Execute the function 'FindClose' to close the file handle provided
. by the 'FindFirstFile' function.
.
WINAPI FindClose GIVING RESULT1 USING FHANDLE
ALERT NOTE,"Complete...",RESULT
STOP
*.........................................................................
. This subroutine determines the file type based on the value found
. in the FileAttr variable.
.
ShowName
.
. The LongName is an ASCIIZ terminated string.
. We want to find the end of the LongName and set the length pointer
. to the character before the binary zero termination character.
.
SCAN TERM,LongName
BUMP LongName, -1
LENSET LongName
RESET LongName
*
. Use the FileData structure FileAttr member to determine the type
. of file being used.
.
. FileAttr Values:
. 128 = Normal File
. 32 = Normal File with Archive Bit Set
. 16 = Directory
.
ADD "1",LINE
IF (LINE = 24)
MOVE "4",LINE
ALERT NOTE,"Continue....",N10
ENDIF
IF (FileAttr = 128 | FileAttr = 32)
MOVE LongName TO NOTE
DISPLAY *P1:LINE,LongName
ENDIF
.
IF (FileAttr = 16)
PACK NOTE WITH "Directory: ",LongName
DISPLAY *P1:LINE,"Directory: ",LongName
ENDIF
.
RETURN
You can’t perform that action at this time.