To create a buffer for the Drop-down data window

Source: Internet
Author: User
Tags copy execution file size functions variables reference access
Data | Dropdown to create a buffer for the Drop-down data window
Zhang Jianji 01-6-22 04:47:33

As with other 4GL tools such as earlier versions of Delphi,visual Basic, PowerBuilder4.0 previously generated executable files using pseudo code, also known as P-code (pseudo-code). P-code is interpreted and executed at runtime, and more accurately, P-code uses virtual machine directives to provide shared operation commands for different host hosts. At runtime, the operating system implements P-code instructions based on different platform interpretations. A p-code instruction can replace several machine code instructions, which reduces the size of the execution code, but at the expense of the execution efficiency of the application. Generally, the p-code is slower to execute than the compiled code, but the file size is less than the compiled code. PowerBuilder 5.0 introduces the ability to generate fully compiled executable code to improve operational efficiency, but it also retains the ability to use P-code as an executable file. Applications that use P-code include execution files. exe and PowerBuilder dynamic Connection libraries. PBD, and the execution files generated by the compiled code are. exe files and dynamic connection library DLLs. What is compiled code compiled code first based on P-code, PowerBuilder first create C code according to P-code, and then compile C code into machine code execution file. In the compiled execution program, all instructions are actual machine code. This means that the size of the execution file will be much larger than the P-code. The PowerBuilder runtime is still required to use the compiled code, and PowerBuilder still uses the shared function library when executing machine code, primarily to conserve memory. Using a dynamic connection library avoids the ability to have all the function lettersThe numbers are written in an executable file to reduce the size of the executable file. In a Windows environment, a copy of a DLL in memory can be used by multiple applications. In addition, PowerBuilder 5.0 also compresses the size of functions in some DLLs, and now the 32-bit platform runs on only 7 dynamic connection libraries, uncompressed 4.5M. Other DLLs required for application such as database access, distributed PowerBuilder, and Rich text editors can be loaded dynamically when used. The creation of compiled code to create a compiled code has the following steps: During the development process, PowerScript was first translated into P-code, when you finished writing an event or letter in the Script editor Number of code back to the window, the system will automatically translate this piece of script code. When you create a p-code executable in an engineering brush, PowerBuilder establishes a connection for references between different objects in different PBL, and copies them to the specified EXE or PBD file. This is a relatively fast process. Next p-code will be translated into the C language statement. In this process, the micro help below the Engineering brush window will show "Compiling ..." ", this process accounts for about 10 of the total compilation time. Then the C code is compiled and linked into machine code, to form executable files and dynamic Connection library, in this step, the micro-help shows "generating ...", the compilation process is the most time-consuming , will account for about 90 of the compile time. From the above, we see that creating machine code takes much more time than generating P-code, because the latter is only a binary generation Code handling process. Therefore, in the development process, we generally use mainly p-code, only in the final delivery of user use, based on the actual situation to choose whether to create machine code. The advantage of compiling code: in the following areas, compiling powerscript code into machine code will get a faster run: · Cyclic structure · Floating-point operations · Integer operations · function calls but in other respects, compiling into machine code does not make it faster to run, such as involving a graphical user interface, database access , decimal operations, string manipulation, and so on. In some cases, the speed of both types of code is the same, such as the invocation of resources and the execution of data windows. In these cases, you will not be able to increase the speed of the operation by using the compiled code. If your application is based on executing your own code, for example, more of the same code is executed repeatedly (such as loops) or the code written is used primarily for mathematical operations. , such an application should use compiled code. The use of machine code is much faster in function invocation than P-code. So if your script calls a large number of functions or invokes the event in a new syntax, using machine code will also be a good choice. However, you should keep in mind that the compiled code has a much larger execution file size than P-code because a powerscript code might compile into 5 or even 10 C code. When these C codes are compiled, the executable code will be much larger than the corresponding P-code, so if your application's file size is the primary consideration for your application , or your application is more database access, you should choose to useP-code. Improve the performance of the application in fact, a good database of physical design and application of the module design can greatly improve the performance of the application. If the application design is not good, even if you use the compiled code, you will not get good system performance. In addition, adjusting the system parameter setting and reasonable physical bandwidth can make the application of PowerBuilder 5.0 run very quickly. In PowerBuilder 5.0, the system has been enhanced within a number of functions, to use these functions, in itself can achieve performance optimization. · When using the tab control for PowerBuilder 5.0, if you select the checkbox "Create on Demand" in TabPage's properties, at run time, only if the user chooses this Tabpage,pow Erbuilder to initialize the instance of the TabPage object. · Use Datastore instead of an invisible DataWindow as a buffer for the data. · Parameters that pass string, DateTime, and other data types use read-only as much as possible, because PowerBuilder does not need to be in memory for these parameters compared to the reference approach Copy a copy. Similarly, the reference method is faster than the value method. Using local variables is faster than global and shared variables, because local variables exist in the stack, and global variables store the Yu Yuan heap. This difference in speed is more pronounced when using machine code than P-code. · Use an array to assign values to DataWindow data instead of using the functions of the SetItem () and GetItem () series, because the former uses only one function, and all rows and columns are called. · To expedite the compilation Speed, do not write too long code in an event or function, dividing it into several functions or other reusable code objects. Adjust your database. Generally speaking, database access takes up a lot of time in the application of client/server structure, and uses PowerBuilder's features to reduce the time of database access, including: 1. In 5.0 dbparm the default setting Staticbind = 1, which means that before retrieving data, PowerBuilder does not first get a description of the query data result set structure, which can improve the number According to the retrieval speed, but if the data window does not match the result set of the database, an error occurs. So if you need to dynamically change the tables that the Data window queries, and if the tables are structured differently, you should set the Staticbind value to 0. 2. The Dbparm default setting allows DataWindow to place BLOB fields, and data Pipeline can be used to insert a BLOB field into the database. 3. The Dbparm settings allow the database to support cursors. Setting Dbparm SQLCache = n tells PowerBuilder how many cursors that use a different SELECT statement will be buffered. If you repeatedly use the same SELECT statement, the retrieval speed will be greatly accelerated when there is data in the buffer. The default value for SQLCache is 0. 4. PowerBuilder 5.0 has an option for the data window to save the result set of the Data window on a local disk. This reduces the use of memory, allowing you to create larger reports, although the access rate is much slower than putting the result set in memory. If your data window will not display a A large report, it is generally better to put the result set in memory. Other considerations for users to compile code using PowerBuilder, there are several points to be noted: · PowerBuilder generate compiled code is slow, should be used as fast as possible to the computer, up to 64M of memory, but in the 5.0 version, the multi-CPU to improve the compilation speed without any Help. · The watcom technology used by PowerBuilder is mainly 32-bit technology, although there are options for generating 16-bit code on 32-bit platforms, but the speed is not good. On the 16-bit platform, we cannot produce 32-bit applications. One of the limitations of compiling a 16-bit application is that neither the code nor the data can exceed 64K, and if the code in the function or event is too long, PowerBuilder will generate an error when creating the EXE. The solution we recommend is to decompose long code into small functions, which can also improve operational efficiency and help you maintain your application code. · If you run a 16-bit application on Windows NT or Windows 95, the runtime you are using should also be 16-bit. · In a PowerBuilder application we can only use P-code PBD or one of the compiled code DLLs and not mix them, but the only exception is to use PowerBuilder to create OLE server. · If you just want to change a DLL and do not want to recompile the full application, you can select library| in the library brush Build Runtime Library ... The menu item. · At compile time, the system will first remove the annotation statement, so how much of the comment statement in the script is to compile speed Degree has no effect. · When you use PowerBuilder's plug-in technology, you cannot use compiled code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.