PowerBuilder Curriculum Part 1
I. Development Specifications
1. Variable naming rules
1 2 3 4 5 |
//Define constants Constant int name = 'PB manual' //1. Global variables (g + variable type abbreviation + variable name) //2. Shared variable (s + variable type abbreviation + variable name) //3. Instance variable (i + variable type abbreviation + variable name |
The following uses global variables as an example
variable type | Naming rules |
Boolean | gbl_ |
string | gs_ |
int | gi_ |
uInt | gui_ |
long | gl_ |
longlong | gll_ |
date | gde_ |
time | gtm_ |
datetime | gdt_ |
decimal | gdc_ |
decimal{2} | gdc2_ |
char | gc_ |
Double | gdb_ |
2. Component naming rules
describe | Component full name | Naming rules |
window | Window | w_ |
data window | DataWindow | dw_ |
d_ | ||
dddw_ | ||
structure | Structure | s_ |
st_ | ||
menu | Menu | m_ |
global function | Function | gf |
window function | WindowFunction | wf_ |
class function | ClassFunction | of_ |
class function | CustomClass | ucc_ |
custom class | StandardClass | usc_ |
standard class | CustomVisual | ucv_ |
Visualization class | ExternalVisual | uev_ |
external visualization class | StandardVisual | usv_ |
3. Regional access rights
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
//1, (public area) The following variable areas are visible to all classes Public: Int a = 1 //2, (private area) The following variable areas are visible in the current class, but not in subclasses Private: Int a = 2 //3. (Protected area) The following variable areas are visible in both the current class and subclasses Protected: Int a = 3 |
4. Variable access rights
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//1. Public permissions Public Int a = 1 //2, private permissions //Only the current class can read and write Private Int a = 1 //Only the current class can write PrivateWrite Int a = 1 //Only the current class can read PrivateRead Int a = 1 //3, protected permissions // Only the current class and subclasses can read and write Protected Int a = 1 //Only the current class and subclasses can write ProtectedWrite Int a = 1 //Only the current class and subclasses can read ProtectedRead Int a = 1 |
5. About Notes
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 |
//1, complete comment /* >==================================================== ==================== > %Script%: %Owner%.%Name% >----------------------------------------------- ------------------- > Description: >----------------------------------------------- ------------------- > Parameters: > %Args% >----------------------------------------------- ------------------- > return value: %Returns% >----------------------------------------------- ------------------- > Developer: %Author% >----------------------------------------------- ------------------- > Development Date: %Date% >----------------------------------------------- ------------------- > %Copyright% >----------------------------------------------- ------------------- > Modification History: >================================================ ========================== */ //2, simple comment /* >==================================================== ==================== > %Status%: >----------------------------------------------- ------------------- > Developer: %Author% >----------------------------------------------- ------------------- > Development Date: %Date% >----------------------------------------------- ------------------- > Description: >==================================================== ==================== */ //3. Brief description /* >==================================================== ==================== > Description: >==================================================== ==================== */ //4, single-line comment /* 5. Multi-line comments */ |
6. String typesetting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
//1, multi-line string typesetting String ls_data ls_data = "1"+& "2" + & "3" MessageBox('prompt', ls_data) //2, multi-line string sequence String ls_data ls_data = "& 1& 2& 3& " MessageBox('prompt', ls_data) |
7. Chain operation
- First define 3 classes (uo_1, uo_2, uo_3)
- Define uo_2 u2 in the instance variable area in the uo_1 class
- Define uo_3 u3 in the instance variable area in the uo_2 class
- Create the of_init operation in the uo_3 class and return ‘success!’
- Start the chain operation call
In the open event under the newly created w_main window, write the following code
1 2 3 4 5 |
String ls_msg uo_1 u1 u1 = Create uo_1 ls_msg = u1.u2.u3.of_init() MessageBox('prompt', ls_msg) |
II. System related
1. Registration and release of DLL
(1), register the dll in the System32 directory
1 |
regsvr32 C:\Windows\System32\ dll-name |
(2), register the dll in the Syswow64 directory
1 |
regsvr32 C:\Windows\Syswow64\ dll-name |
(3), register the dll in other directories
1 |
regsvr32 directory path/dll name |
(4), register all dll
1 |
for %i in (c:\windows\system32\*.dll) do regsvr32.exe /s %i |
(5), cancel the registered dll
1 |
regsvr32 /u DLL component name. |
2. Detailed definition of DLL
Use library to declare dynamic library
1. The function declaration of the common standard library DLL:
1 |
Function Long test() Library "test.dll" |
2. If it is a DLL of a version below PB9, when upgrading to a higher version, it will automatically add ;ansi, which becomes:
1 |
Function Long test() Library "test.dll" Alias For "test;ansi" |
3. Definition of PB10 and above:
1 |
FUNCTION ulong SetWindowText(ulong hwnd,ref string lpString) LIBRARY "user32.dll" ALIAS FOR "SetWindowTextW" |
Note that ;ansi is not added, but the last A is changed to W, indicating that the UNICODE encoding is used.
Use system library to declare dynamic library
1 |
Function Long systest() System Library "test.dll" Alias For "systest" |
The difference between library and system library definitions
Library (foreign workers) system library (PB own people)
In fact, all the functions we use in PB exist in PBVMxxx.DLL in the form of system library.
For example: If you don’t like the name MessageBox, you want to use the name MsgBox, and all functions should be the same.
A function can be declared like this:
1 2 3 4 |
//Assume it is PB9 Function Int MsgBox(String Title,String Text) System Library "pbvm90.dll" Alias For "fnMessageBox" //Assume it is PB10 Function Int MsgBox(String Title,String Text) System Library "pbvm100.dll" Alias For "fnMessageBox" |
Benefits of using system library definitions
For functions declared in system librar mode, PB will not automatically add “;ansi” even if it is upgraded from PB9 to a higher version, which is convenient
Subsequent upgrade and maintenance
III. window
1.Branch statement and loop
(1). if
1 2 3 4 5 |
If 1 = 1 Then MessageBox('prompt','equal') Else MessageBox('prompt','not equal') End If |
(2), choose
1 2 3 4 5 6 7 8 9 10 |
Choose Case variable Case Value 1 MessageBox('Prompt', 'I am 1') Case Value 2 MessageBox('reminder', 'I am 2') Case Value 3 MessageBox('reminder', 'I am 3') Case Else MessageBox('reminder', 'If there is none, then come to me') End Choose |
(3), try
1 2 3 4 5 6 7 8 9 10 |
String ls_arr[1], ls_test Try ls_test = ls_arr[2] Catch(runtimeerror r) MessageBox('Runtime exception prompt', r.ClassName() + '~r~n' + r.getmessage()) Catch(throwable t) MessageBox('Other exception prompts', t.ClassName() + '~r~n' + t.getmessage()) Finally MessageBox('prompt', 'will be executed no matter what') End Try |
(4), for
1 2 3 4 5 6 7 8 9 |
//Syntax 1 For i = 1 To 99 i++ Next //Syntax 2 For i = 1 To 99 Step 2 i++ Next |
(5), do until
1 2 3 4 5 6 7 8 9 |
//When the condition is false, the body of the loop is executed. When the condition is true, jump out of the loop body //Syntax 1 Do Until i > 99 Loop //Syntax 2 Do Loop Until i > 99 |
(6), do while
1 2 3 4 5 6 7 8 |
//When the condition is true, execute the loop body. When the condition is false, jump out of the loop body //Syntax 1 Do While i > 99 Loop //Syntax 2 Do Loop While i > 99 |
(7), continue, exit, goto
1 2 3 4 5 6 7 8 9 |
//1. continue can only be used in do...loop and for...next statements. When a continue statement is encountered, the continue will not be executed The above statement, jump back To The Loop condition To Continue execution //2. The exit statement can only be used in do...loop and for...next statements. When an exit statement is encountered, the loop will end //3, goto The goto statement can jump out of the loop or any position directly For i = 1 To 10 If i = 3 Then go To a End If End If a; |
(8), null
1 2 3 4 5 6 7 8 9 10 |
//null judgment String ls_test ls_test = '1' If IsNull(ls_test) Then MessageBox('prompt','empty') ElseIf Not IsNull(ls_test) Then MessageBox('prompt','not empty') End If // set to null SetNull(ls_test) |
2. Event
event | description |
activate | Occurs before the window is activated. After this event occurs, the object with the smallest sequence number gets the focus. If there is no sequence number, the window itself gets the focus. |
clicked | Occurs when the user clicks an empty area of the window that cannot contain any space or data windows |
close | Occurs when the window is closed. After triggering this event, there is no way to prevent the closing of the window Occurs when the window starts to close. This event returns a return value of 0 or 1. If |
closequery | the return value is 1, the window is not closed, and the close event will not be generated. If the return value is 0, the window is closed. |
deactivate | Occurs when a window becomes inactive |
doubleclicked | Occurs when the user double-clicks an empty area of the window that cannot contain any space or data windows |
dragleave | Occurs when a draggable object or control leaves an empty space |
dragwithin | Occurs when a draggable object, or control, is dragged in the window |
hotlinkalarm | Occurs when the Dynamic Data Exchange (DDE) server application has sent new (modified) data and the client DDE application has received the data |
key | Occurs when the user presses a key on the keyboard and the insertion point is not in the editing area |
mousedown | Empty space, which occurs when the mouse is left-clicked. This event is the same as the click event, the value of flags is always 1 |
mousemove | Occurs when the mouse is moved in the window |
mouseup | Occurs when the left mouse button is released |
open | Occurs after the window is opened, but before the display |
rbuttondown | Empty space, occurs when the right mouse button is pressed |
remoteexec | Occurs when a DDE client application sends a command |
remotehotlinkstart | Occurs when a DDE client application wants to start a hotlink |
remotehotlinkstop | Occurs when a DDE client application terminates a hotlink |
remoterequest | Occurs when a DDE client application requests data |
remotesend | Generated when a DDE client application has sent data |
resize | When the window size changes, this event is also triggered when the window is opened |
systemkey | Occurs when the insertion point is not in the edit box and the user presses [alt] or [alt+other key combination] |
timer | Call the timer function to start the timer and set the time to occur |
toolbarmoved | Occurs when a toolbar in an MDI window is moved |
3. Parameter transmission and reception
(1), string
1 2 3 4 5 |
//1. Open a window and pass a string OpenWithParm(window Name,'1') //2, receive the string String ls_str ls_str = Message.StringParm |
(2), value
1 2 3 4 5 |
//1. Open a window and pass a value OpenWithParm(windowname,1) //2, receive the value Long ll_row ll_row = Message. DoubleParm |
(3), structure
1 2 3 4 5 6 7 8 |
//1. Open a window and pass a structure st_parameter s_pm s_pm.a = 1 OpenWithParm(window Name, s_pm) //2. Receive structure st_parameter s_pm s_pm = Message.PowerObjectParm MessageBox('reminder', s_pm.a) |
(4), User Object
1 2 3 4 5 6 7 8 9 10 11 |
//1. Open a window and pass a user object (1) Create a Class user Object u_parameter (note: If it Is Not an automatically instantiated Application Object, you should Create it), And define instance variable (2), assign a Value To the user Object, And pass the user Object u_parameter u_pm u_pm.a = '1' OpenWithParm(window Name, u_pm) //2, receive the user object u_parameter u_pm u_pm = Message.PowerObjectParm MessageBox('reminder',u_pm.a) |
(5), exe
1 2 3 4 5 6 |
1. Open an exe And pass parameters ls_exe = 'a.exe' + '|value1|' + '|value2|' Run(ls_exe) 2. Receive the parameters passed By exe String ls_parameter ls_parameter = CommandParm() |
(6), send messages and receive messages
1 2 3 4 5 6 7 8 9 10 |
//1, pass string message w_main.TriggerEvent('ue_open',0,'test') //Receive messages in user-defined event ue_open: String ls_msg ls_msg = String(Message. LongParm,'address') //2, pass long message w_main.TriggerEvent('ue_open',100,0) //Receive messages in user-defined event ue_open: Long ll_msg ll_msg = Message.WordParm |
(7), visual class value passing
1 2 3 |
u_customvisual u_cv u_cv = Create u_customvisual OpenUserObjectWithParm(u_cv,1) |
4. Triggering events and functions
(1), trigger immediately
1 2 3 |
obj.TriggerEvent(Clicked!) obj.Trigger Event ue_init() obj.Trigger Function wf_init() |
(2), triggered at the end of the event queue
1 2 3 |
obj.PostEvent(Clicked!) obj.Post Event ue_init() obj.Post Function wf_init() |
(3) Dynamic binding trigger
1 2 |
obj.Dynamic Event ue_init() obj.Dynamic Function wf_init() |
Note:
The difference between dynamic call and static call
Static call is to compile the function completely when compiling the code
Dynamic call is to go back to find and call the corresponding function when the program is executed
(4) Trigger an event within the specified time
1 2 |
idle(60) //Trigger the idle event of the application object if there is no operation for 60 seconds timer(60) //Trigger the timer event of the window every 60 seconds |
5. Various time acquisition
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 |
//1. Get [Date + Time] DateTime ldt_dqsj ldt_dqsj = DateTime(Today(),Now()) //2. Get [Date] String ls_dqrq ls_dqrq = String(Today(),'yyyy-mm-dd') //3. Get the [Date + Time] Of the SqlServer Database DateTime ldt_server_time Select getdate() Into :ldt_server_time From Table Name; //4. Display [Date + Time] In the Data window String(Today(),'yyyy-mm-dd hh:mm:ss') //5. String To [Date+Time] Format String(String,"yyyy-mm-dd hh:mm:ss") //6. Get the Time From 0 o'clock to 23:59:59 seconds (1), method 1 em_kssj.Text = String(DateTime(Today(),Time("00:00:00"))) em_jssj.Text = String(DateTime(Today(),Time("23:59:59"))) (2), method 2 em_kssj.Text = String(DateTime(Today(), 00:00:00)) em_jssj.Text = String(DateTime(Today(),23:59:59)) //7. Calculate age By Date (SQL statement) Select (Year(getdate())-Year('date of birth')) From Table Name; //8. Convert string format to datetime format String ls_rq String ls_sj ls_rq = Mid(ls_datetime,1,10) ls_sj = Mid(ls_datetime,12,21) MessageBox('reminder',String(DateTime(Date(ls_rq),Time(ls_sj)) //9. Convert date And time to datetiem format Date lde_rq Time ltm_sj lde_rq = 2022-04-15 ltm_sj = 10:10:10 MessageBox('reminder', String(DateTime(lde_rq,ltm_sj))) //or MessageBox('reminder', String(DateTime(2022-04-15,10:10:10))) |
6. Cursor
(1), for
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Long ll_count = 10 //Define the cursor String test //declare cursor Declare test Cursor For Select field Name From Table Name Where expression Using sqlca; // open the cursor Open test; For i = 1 To ll_count //retrieve data Fetch test Into: variable Name; // write your business here Next //Close the cursor Close test; |
(2), do while
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
//Define the cursor String test //declare cursor Declare test Cursor For Select field Name From Table Name Where condition Using sqlca; // open the cursor Open test; //retrieve data Fetch test Into: field Name variable; Do While sqlca.SQLCode = 0 // write your business here //get data again Fetch test Into: field Name variable; Loop //Close the cursor Close test; |
7. Stored procedure
(1), processing the result set
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 |
String ls_stuno String ls_stuname String ls_stuage String ls_stusex String ls_result Integer fetchcount = 0 ls_stuno = '06' ls_stuname = 'Zhang San' ls_stuage = '1980-01-01' ls_stusex = 'male' //Declare the stored procedure name here Declare emp_proc Procedure For stu11 @stuno = :ls_stuno, @stuname = :ls_stuname, @stuage = :ls_stuage, @stusex = :ls_stusex, @result = :ls_result output Using sqlca; //execute stored procedure Execute emp_proc; Choose Case sqlca.SQLCode Case 0 //Process the result set Do Fetch emp_proc Into:ls_result; Choose Case sqlca.SQLCode Case 0 MessageBox('result set', ls_result) fetchcount++ Case 100 Commit Using sqlca; MessageBox ("result set end", 'total execution' + String (fetchcount) + " pieces of data") case-1 Rollback Using sqlca; MessageBox ("Failed to obtain the result set of the stored procedure", String (sqlca.SQLDBCode) + " = " + sqlca.SQLErrText) End Choose Loop While sqlca.SQLCode = 0 Case 100 Rollback Using sqlca; MessageBox ("Execution succeeded", "No result set") Case Else Rollback Using sqlca; MessageBox ("Stored procedure execution failed", String (sqlca.SQLDBCode) + " = " + sqlca.SQLErrText) End Choose //Close the stored procedure Close emp_proc; |
(2), process return value
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 |
String ls_stuno String ls_stuname String ls_stuage String ls_stusex String ls_result Integer fetchcount = 0 ls_stuno = '06' ls_stuname = 'Zhang San' ls_stuage = '1980-01-01' ls_stusex = 'male' //Declare the stored procedure name here Declare emp_proc Procedure For stu11 @stuno = :ls_stuno, @stuname = :ls_stuname, @stuage = :ls_stuage, @stusex = :ls_stusex, @result = :ls_result output Using sqlca; //execute stored procedure Execute emp_proc; Choose Case sqlca.SQLCode Case 0 // Execute a fetch statement to get the return value and output parameters Fetch emp_proc Into:ls_result; Choose Case sqlca.SQLCode Case 0 Commit Using sqlca; MessageBox ("Get the return value and output parameters successfully", "The return value is: " + String (ls_result)) Case 100 MessageBox ("prompt", "return value and output parameters not found") Case Else Rollback Using sqlca; MessageBox ("Failed to get the return value and output parameters", "sqldbcode is " + String (sqlca.SQLDBCode) + " = " + sqlca.SQLErrText) End Choose Case 100 Rollback Using sqlca; MessageBox ("Execution succeeded", "No result set") Case Else Rollback Using sqlca; MessageBox ("Stored procedure execution failed", String (sqlca.SQLDBCode) + " = " + sqlca.SQLErrText) End Choose //Close the stored procedure Close emp_proc; |
8. Execute the sql statement directly in pb
1 2 3 4 5 6 7 8 9 10 11 |
String ls_sql, ls_err ls_sql = "update table name set field name =: field value where expression condition" Execute Immediate : ls_sql Using sqlca; If sqlca.SQLCode = 0 Then Commit Using sqlca; MessageBox('prompt', 'executed successfully') Else ls_err = sqlca.SQLErrText Rollback Using sqlca; MessageBox('prompt','execution failed' + ls_err) End If |
9. Error reminder and pop-up window
(1), custom program error reminder
In the systemerror event of the current application, add the following code
1 2 3 4 5 6 7 8 |
String ls_errmsg ls_errmsg = "System error:~r~n" ls_errmsg += "Error number: " + String(Error.Number) + ";~r~n" ls_errmsg += "Error message: " + String(Error.Text) + ";~r~n" ls_errmsg += "Error object: " + String(Error.Object) + ";~r~n" ls_errmsg += "Error event: " + String(Error.ObjectEvent) + ";~r~n" ls_errmsg += "Error line: " + String(Error.Line) + ";~r~n" MessageBox('system error', ls_errmsg) |
(2), pop-up window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
MessageBox (Title, content, Icon On the Left, button at the bottom Of the dialog box, button Number) //1. Icons On the Left //1. information! Default Value //2. stopsign! //3. Exclamation! //4. question! //5. None! //2. Buttons at the bottom Of the dialog //1. ok! (Default Value) //2. okcancel! //3. yes no! //4. yes no Cancel! //5. retry Cancel! //6. abort retry ignore! //example: If MessageBox('Prompt', 'Do you want to do this?',question!,yesno!) = 1 Then MessageBox('prompt','yes') Else MessageBox('Prompt','No') End If |
10. Shortcut keys
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
//1. Set the external function Subroutine keybd_event(Int bVk, Int bScan, ULong dwFlags, ULong dwExtraInfo) Library "user32.dll" //2. Write the following code in the key event If Key = KeyEnter! Or Key = KeyRightArrow! Then //Determine the name of the control corresponding to the focus Choose Case GetFocus(). ClassName() Case 'sle_1 MessageBox('1','1') Case 'sle_2' MessageBox('2','2') Case Else End Choose //Press the tab key after processing keybd_event( 9,0,0,0 ) // press tab keybd_event( 9,0,2,0 ) // release tab End If //3. Code meaning (reference address: https: //baike.baidu.com/item/keybd_event/6372528) //Key Description keybd_event( 9,0,0,0 ) // press tab keybd_event( 9,0,2,0 ) // release tab keybd_event( 16,0,0,0 ) // press shift keybd_event( 16,0,2,0 ) // release shift // Get the current control name (optional) GetFocus(). ClassName() |
Key-value comparison Table
Alphabetic and numeric keys | keys of the numeric keypad | function key | other keys | ||||
key | key code | key | key code | key | key code | key | key code |
A | 65 | 0 | 96 | F1 | 112 | Backspace | 8 |
B | 66 | 1 | 97 | F2 | 113 | Tab | 9 |
C | 67 | 2 | 98 | F3 | 114 | Clear | 12 |
D | 68 | 3 | 99 | F4 | 115 | Enter | 13 |
E | 69 | 4 | 100 | F5 | 116 | Shift | 16 |
F | 70 | 5 | 101 | F6 | 117 | Control | 17 |
G | 71 | 6 | 102 | F7 | 118 | Alt | 18 |
H | 72 | 7 | 103 | F8 | 119 | Caps Lock | 20 |
I | 73 | 8 | 104 | F9 | 120 | Esc | 27 |
J | 74 | 9 | 105 | F10 | 121 | Spacebar | 32 |
K | 75 | * | 106 | F11 | 122 | Page Up | 33 |
L | 76 | + | 107 | F12 | 123 | Page Down | 34 |
M | 77 | Enter | 108 | — | — | End | 35 |
N | 78 | – | 109 | — | — | Home | 36 |
O | 79 | . | 110 | — | — | Left Arrow | 37 |
P | 80 | / | 111 | — | — | Up Arrow | 38 |
Q | 81 | — | — | — | — | Right Arrow | 39 |
R | 82 | — | — | — | — | Down Arrow | 40 |
S | 83 | — | — | — | — | Insert | 45 |
T | 84 | — | — | — | — | Delete | 46 |
U | 85 | — | — | — | — | Help | 47 |
V | 86 | — | — | — | — | Num Lock | 144 |
W | 87 | ||||||
X | 88 | ||||||
Y | 89 | ||||||
Z | 90 | ||||||
0 | 48 | ||||||
1 | 49 | ||||||
2 | 50 | ||||||
3 | 51 | ||||||
4 | 52 | ||||||
5 | 53 | ||||||
6 | 54 | ||||||
7 | 55 | ||||||
8 | 56 | ||||||
9 | 57 |
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 |
0x1 Left mouse button 0x2 Right mouse button 0x3 Cancel Key 0x4 middle mouse button 0x8 Backspace Key 0x9 Tab Key 0xC Clear Key 0xD Enter Key 0x10 Shift Key 0x11 CTRL Key 0x12 MENU Key 0x13 PAUSE Key 0x14 Caps Lock Key 0x1B Esc Key 0x20 Spacebar Key 0x21 Page Up Key 0x22 Page Down Key 0x23 End Key 0x24 Home Key 0x25 Left Arrow Key 0x26 Up Arrow Key 0x27 Right Arrow Key 0x28 Down Arrow Key 0x29 Select Key 0x2A Print SCREEN Key 0x2B Execute Key 0x2C SNAPSHOT Key 0x2D Insert Key 0x2E Delete Key 0x2F Help Key 0x90 Num Lock Key The A To Z keys have The same ASCII codes as The A To Z letters: Value description 65 A Key 66 B Key 67 C Key 68 D Key 69 E Key 70 F Key 71 G Key 72 H Key 73 I Key 74 J Key 75 K keys 76 L Key 77 M Key 78 N Key 79 O Key 80 P Key 81 Q Key 82 R Key 83 S Key 84 T Key 85 U Key 86 V keys 87 W Key 88 X keys 89 Y Key 90 Z Key The 0 To 9 keys have The same ASCII codes as The numbers 0 To 9: Value description 48 0 keys 49 1 Key 50 2 keys 51 3 keys 52 4 keys 53 5 keys 54 6 keys 55 7 keys 56 8 keys 57 9 keys The following constants represent keys On The numeric keypad: Value description 0x60 0 Key 0x61 1 Key 0x62 2 keys 0x63 3 keys 0x64 4 keys 0x65 5 keys 0x66 6 keys 0x67 7 keys 0x68 8 keys 0x69 9 keys 0x6A MULTIPLICATION Sign (*) Key 0x6B PLUS Sign (+) Key 0x6C Enter Key 0x6D MINUS Sign (–) Key 0x6E Decimal POINT (.) Key 0x6F DIVISION Sign (/) Key The following constants represent Function keys: Value description 0x70 F1 Key 0x71 F2 Key 0x72 F3 Key 0x73 F4 Key 0x74 F5 Key 0x75 F6 Key 11. Access The web Address 12. Display The Name Of The window being edited //You can write to the open event, open the window, and the window title will display the current window file name 13. Others (1), allocate Space To Variables (2), locate The breakpoint Position (3), get The current project path 0x76 F7 Key 0x77 F8 Key 0x78 F9 Key 0x79 F10 Key 0x7A F11 Key 0x7B F12 Key 0x7C F13 Key 0x7D F14 Key 0x7E F15 Key 0x7F F16 Key |
11. Access the web address
1 2 3 4 5 6 7 8 9 10 11 |
//method 1 Inet iinet_base GetContextService("Internet", iinet_base) iinet_base.HyperLinkToURL(shl_1.Text) //Method 2 String ls_url ls_url = shl_1.Text Inet iinet_base GetContextService("Internet", iinet_base) iinet_base.HyperLinkToURL(ls_url) |
12. Display the name of the window being edited
1 2 3 4 5 6 |
// You can write to the open event, open the window, and the window title will display the current window file name If Handle(GetApplication()) = 0 Then This.Title = This.Title + '(' + This.ClassName() + ')' End If Return |
13. Others
(1), allocate space to variables
1 2 |
String ls_test ls_test = Space(1024) |
(2), locate the breakpoint position
1 |
DebugBreak() |
(3), get the current project path
1 |
getcurrentdirectory() |
(4), read and write ini files
1 2 |
profilestring(getcurrentdirectory() + "\pb.ini","pb","abc","I'm alternate default") setProfilestring(getcurrentdirectory() + "\pb.ini","pb","abc","I am the parameter to be written") |
(5), create and delete objects
1 2 |
Create // create an object Destroy //delete an object |
(6), database connection and disconnection
1 2 |
Connect Using sqlca; //connection Disconnect Using sqlca; //disconnect |
(7), transaction commit and rollback
1 2 |
Commit Using sqlca; //submit Rollback Using sqlca; //rollback |
(8), set the control focus
1 |
Control name.setfocus() |
PowerBuilder Manual Book Part 2 ClickHere
Good Luck!