123 Tips & Tricks Of PowerBuilder

Collection PowerBuilder Tips & Tricks. Get From The Internet

Tips 1: Changing DataWindow object by code methods

Tips 2: Open dynamic window approach

Tips 3: Displays a consistent style with the Windows operating system About dialog. First, the following statement external function:

Tips 4: How COLUMN display style between EDIT, DDDW, DDLB switch between

Tips 5: Few records you want to print selected in the dw_1

Tips 6: Achieved when the cycle is terminated by clicking the button loop

Tips 7: SQL statement calling convention

Tips 8: Modify function by modifying multiple tables simultaneously

Tips 9: Click Edit marquee in which the content

GetFocus Event Write code: This.SelectText (1, Len (This.Text)). Save Running, Do Not Get what we want Effect. Think Of an alternative approach: To pbm_bnclicked For the Event ID, Create a single-line EDIT box custom Event ue_clicked,
code Is: This.SelectText (1, Len (This.Text)),
code GetFocus Event changed: This.Post Event ue_clicked (). After the Save operation, the Effect came out!

Tips 10: How to get the number of characters in the string

Tips 11: Finally, li_num is the number of characters

Tips 12: DW support press Ctrl or Shift-click to select more than Line

Tips 13: DW queries change conditional statements

Tips 14: Datawindow: Tips to save data

Tips 15: Select to delete records

Tips 16: Sorted by a field

Tips 17: Control DATAWINDOW in the number of rows displayed per page

Tips 18: How to achieve data window data automatically wrap

1) Open the Datawindow Object In the Datawindow Painter.
2) Double-click the mouse On a column In the need To Set up Automatic fold Line, bounced off the properties window For This column.
3) Select the Position tab, Select AutoSize Height checkbox.
4) Select the EDIT tab And Uncheck Auto Horz Scroll checkbox.
5) click the OK button To Save your changes.
6) points Detail Band (ie Write Long belt Detail gray), And click the Right mouse button And Select properties … menu Item.
7) Select the AutoSize Height checkbox.
8) click the OK button To Save your changes.
9) Save the Datawindow.
Note: the characters together (With no punctuation Or spaces), the System will be considered as a word, does Not automatically wrap,
English Is also True …… DW window wrap If there are characters, Then it will be necessary To wrap the intermediate spaces, otherwise how To Set up will Not work. For example, you
If you want To fold In the First 20 Rows, you First determine whether it Is the First 20 characters, If Not To put a Space After the First 20, If the characters In the
the First 19 spaces. determine whether the characters In the ASCII code can use it To determine whether it Is greater than 127.

Tips 19: By conditions on color-coded data in a row

Tips 20: PB simultaneously connect to multiple databases, such as connecting SQLServer2000 and Oracle8

Tips 21: Connection Oracle8i and 9i of

Tips 22: Retrieving data rows in a row plus

Tips 23: DataWindow, press the enter key to achieve tab function (in Enter event data window)

Tips 24: send usage: Send (handle, message #, lowword, long)

Tips 25: Reset search statement data window

Tips 26: PB standard sql statement calling

Tips 27: PB standard cycle call sql statement

Tips 28: Generic Script window open event

Tips 29: Query button Generic Script

Tips 30: Add button Generic Script

Tips 31: Delete button Generic Script

Tips 32: Save button Generic Script

Tips 33: Print button Generic Script

Tips 34: Export button Generic Script

Tips 35: Import button Generic Script

Tips 36: Exit button Generic Script

Tips 37: Generic script calling process

Tips 38: PB some controls Chinese display problems

If PB’s ListView can not properly display Chinese, you should set the ListView’s FontCharSet property Into Other types. the Export ListView Where the Object Into the Source code. Find ListView definition section In the Source code, which will FontCharSet property Into DefaultCharSet! If Other controls PB corresponding phenomenon also occurs when the same adjustments To its FontCharSet properties. General Speaking For Simplified Chinese fonts In Chinese WINDOWS environment should be Set To DefaultCharSet !. Display Chinese Control In Question it’s FontChatSet property forcibly set to DefaultCharSet! Should be no problem. Or change the font !!!

Tips 39: Data type conversion

Conversion Between numeric types automatically By the System, usually converted To high-level accuracy based On the operator To participate In operations.
Precision numeric types From high To low priority as follows:
Double ← Real ← Decimal ← UnsignedLong, Long ← UnsignedInteger
String To numeric Type Conversion functions:
Integer (str), Long (str), Real (str), Double (str), Dec (str)
numeric To String Conversion Function Is:
String (Number, Format), Number Is Any numeric Type, Format After Format Conversion instructions can usually be omitted.

Tips 40: Pronouns

This: This representative Of the window, the user Object, menu, Application Object Or Control itself, which represents the Object being To whom To Write Event handlers.
Parent: Parent refers To the window Where the current Control.
ParentWindow: ParentWindow representative runtime menu window Where the pronoun used only In the Event handler menu.
Super: when writing a Control sub-objects Or Object, the child Object can Call the Parent Object’s event handler, the program can directly use the Name Of the Parent Object To Call them, can also be used To refer To Super pronouns. For example, when you want To Call the Parent Object’s Clicked event handler, sub-objects can be written: Call Super :: Clicked

Tips 41: System of five predefined global variables

SQLCA, sqlda, SQLSA, Error, Message

Tips 42: Relationship in PowerBuilder and RGB color values between the values as follows:

Color = R * 256 * 256 + G * 256 + b

Tips 43: There are fourteen kinds of standard data types

Blob binary large Object, used To store large amounts Of Data, such as images, large Text, etc., such as: Blob {100} ib_test // length 100
Boolean Boolean, Boolean variable has only two possible Values : True Or False
Char Or Character, a single ASCII Character
Date Date, including the Year (1000-3000), Month (01-12), 1999 (01-31)
DateTime Data Type DateTime Date And Time, only For Database Access
Dec Or Decimal, signed Decimal Number, maximum 18 Precision, such as: Dec {2} ld_test // 2-bit precision
Double floating-point Number With Sign, 15 significant digits
Int Or Integer, 16-bit signed Integer
Long 32-bit signed Integer
Real signed floating Point Precision 6
String String Type, ASCII characters used To store an arbitrary Length Of 0 To 60,000 (16 environments), 32 environment Length Limited only By the capacity Of the System. when the program writes directly To the String, use single quotation marks (‘) or double quotes (“) to enclose the string the Default Value Is an empty String (“”)
Time 24-Hour Time, including the Hour (00 To 23), points (00 To 59), Second (00 To 59) And the Second Decimal place (up To six), Range From 00:00:00 To 23:59: 59: 999999
UInt Or UnsignedInteger, UnsignedInt, 16-bit unsigned Integer ranging From 0 To 65,535
ULong Or UnsignedLong, 32-bit unsigned Integer ranging From 0 To 4,294,976,295
Any Type Of Any variable In Order To know the Type Of stored Data, you can use the Function ClassName ()

Tips 44: How pictures will be stored into the database

define a Bolb variable lb_file, the file Read lb_file, With insertblob Or UpdateBlob On OK

Tips 45: Variable scope

Global Variables: the entire Application can Access, its scope Is the entire Application
Instance Variables: the Object Is associated With, only be used For the Object Instance Variables defined In the Event handler Or Function Of the Object.
Instance Variables when it Is associated With an Object created Is opened, when it Is closed To disappear
Shared Variables: a Static variable, which means Not only share when it opened again After the Object Is closed Object variable remains closed Value, But also means keeping multiple instances Of the same Value With the same Name In a Class Shared Variables
Local Variables: the use Of its Event handler Or Function described In its scope Is Limited To the description Of its program segment, Any segment Of the program Places can Access Local Variables, But Other programs can Access This section block Local Variables. After Running the program, enter when a program segment, the System automatically allocates memory For Local Variables, when you Exit the program segment, the memory Of Local Variables Is released.

Tips 46: exit, continue, return

1.Exit (Exit Loop): Do … Loop And For … Next Loop statement, when we wanted To quit In the middle Of the cycle when the Exit statement, Control procedures go To the statement After the Loop, In the Case Of nested loops, Exit statement To Exit the current Level circulation, But Not All cycles.
2.Continue (continued circulation): In the body Of the Loop Do … Loop And For … Next statement, After encountering Continue statement, After the End Of the cycle does Not Execute Continue statement All statements before, And began a new Round Of circulation.
3.Return statement: Return Control To the user Or the calling Function Places. (when the termination Of the Application you want To Run, use the Halt statement), the Immediate termination Of the Event processing execution Of the program Or Function, the Control Is returned To the calling program when the Return statement at the Event handler And a user action triggers the Event After the treatment program, the implementation Of the Return statement, which immediately terminates the execution Of the Event handler And waits For the user’s next operation when the program when calling a Function Or Event handler, After executing the Return statement, which immediately terminates execution Event handler Or Function, And To Control Is returned To the calling program.
4.Halt {Close} statement: Halt statement Is used To terminate the Application To Run when Halt Close statement With no Options, the statement immediately terminate Running applications.; when Halt statement With Close option, After execution To the statement, the Application To Execute the Application Object Close Event handler, And Then re-terminate the Application.

Tips 47: DataWindow Buffer

Primary buffer, Filter buffer, Delete buffer, original buffer when we Read the Data From the Database, All Data will be placed In the main buffer (Primary buffer), And will put a Copy Of the original Buffer (original buffer) within In the Data window we can see the Data the main buffer (Primary buffer) within Any Data processing are also doing the main buffer For Data processing, But remember, no matter what we Do the Data In the buffer zone Of Any treatment, Unless we Run the Update () Function, no changes To the Data In the buffer, For the back-end Database without Any Effect.

Tips 48: How to generate a fixed-length front plus zero digits, for example: 12 generation “00012” 1234 generation “01234.” The method is simple:

Tips 49: row represents the number of rows, col represents the field name, val represents the value

Tips 50: Read data

Tips 51: How to Grid-based datawindow into Tabular type

Export Data window Into .srd file, use Notepad To Open the processing = 1 Into processing = 0

Tips 52: Yield () function

Yield () Is a Function Not used To PowerBuilder. However, a large Loop In the process, If the user wants To perform half By clicking a button Or menu To Exit, Then it must use To Yield () Function, otherwise the program will complete the entire cycle will be executed After Respond To the click Event Of the button Or menu. the Yield () Function In the middle Of the Loop body. So Find that during the execution Of the Loop has something new Pieces Of messages In the Message queue And returned immediately To Respond.

Tips 53: sqlca.SQLCode

when Using Embedded SQL For each SQL command you should Run a Check once the Transaction Object attributes SQLCode, rather than wait Until All SQL command has finished Running And Then go Run a Check Transaction Object SQLCode properties. when the Function we use the Data provided By the window, the Do you want To remember To Check SQLCode To determine whether the Run was successful. But To every Function In accordance With the Value Of the Return Run To determine whether To Run Success.

Tips 54: To ensure the Success Of the Data stored

Tips 55: In PB how to open a file (such as .txt, .doc), just like in Explorer, double-click to open the file the same

Tips 56: Insert a row after a default value to the default value but do not modify, CloseQuery event does not excite method

Tips 57: Value of a column with a data window is retrieved based on the value of another column (on itemchanged event in DW)

Tips 58: Dynamic DataWindow

Tips 59: Read multiple rows of data

Tips 60: Dynamic SQL (There are four types)

Tips 61: Get the display value of the pull-down data window

Tips 62: Previous column method of fixing the datawindow, for example, the first column called “id”, fixed the column and started to show from the second half of the next column:

Tips 63: Print data window last one approach

Tips 64: When the edit box to get focus automatically selected content

Tips 65: If more than 23 this month, will be the 1st time is set for next month, otherwise take the current time

Tips 66: Allows the user to modify the newly added records, and the records retrieved are not allowed to modify.

Tips 67: Ole object, such as when using the communication with the Word, how to avoid multiple Word and other programs to start

Tips 68: Call screen protection method in PowerBuilder

Tips 69: Get path when the program is running

Tips 70: Editing style columns dynamically set in the program for the pull-down data window (DropDownDataWindow)

Tips 71: Incremental search function realization

Tips 72: How in the program written for the database BLOB

Tips 73: How to remove content DDDW the Display Column of

Tips 74: Shielded window ALT + F4 keys

Tips 75: How to achieve in PB delay

Tips 76 : With the following expression can be obtained in a certain group recorded line number:

Tips 77: Call the API function steps

Tips 78: GRID format data under the window, according to the actual situation of each row to control the background

Tips 79: Achieve the data window of a column / row is displayed as a specified color

Tips 80: In the data window How to hide a computing unit

Set In its properties \ expression \ visible property “IF (1 = 2,1,0)” on it.

Tips 81: Hyperlink

Tips 82: get value of the expression

Tips 83: Commonly used API functions by example

Tips 84: PB of SHELL command

Tips 85: PB key code constants described

Tips 86: PowerBuilder system tables

Tips 87: In the datawindow after which press the Enter key, the focus moves to the back of the field, such as from the last movement, then automatically jump to the next line

Tips 88: Window among the enter event

Tips 89 : How in the program for datawindow plus computational domain or line

Tips 90: A window redraw the screen in the middle of the function

Tips 91: How to get the path of the current application

Tips 92: Get the current name of the computer

Tips 93: Get the current path