Forehead
The programming tool on Windods is changing in the day, and it is very poor, and its programming tool is very poor due to the limitations of UNIX use. In UNIX, you must do a picture, menu, query, input, and programmer tend to start from the bottom, repeat labor, and extremely low efficiency. In order to solve this problem, I will introduce this system to you. If you can read this article, you have a lot of harvest. Editor: Wang Guanghong
Email: wgh166@hotmail.com WGHSoftware@hotmail.com Software Download: http://www.9cbs.net/cnshare/soft/16/16735.shtm http://www.ccrun.com/program/down.asp? ID = 10
One. System internet
(1) Implementation: Used for the screen, menu, query, input, modification; operable database.
(2) Design Idea: Dialogue can be divided into two major categories of basic input and output. In this preceding, for different needs to divide a variety of types; a table name related to the domain of the database , Field name to read and write the database. A functional module is implemented in an Form in an Form. Put the Form number, in binary form in binary, in use, the system reads the form of FORM, and press step to implement a predetermined function.
(3) Software Environment: 1. Operating system SCO UNIX OPENSERVER 5.0, SCO UNIX OpenServer 3.0, Sco Unix 3.0. 2. Programming Language C, Informix / ESQL. Note: The author's working conditions are limited to the above environment, such as providing other UNIX, SQL databases, such as Oracle, Sybase, etc., the system only needs to be modified.
two. System files and libraries
(1) Integrated Developer Execute Procedure: / USR / WFORM / BIN / MKFORM FORM Custom Tool / USR / WFORM / BIN / NETFORM FORM Custom Tool (Web version) / USR / WFORM / BIN / NET_SERVER FORM data server
(2) Profile: The path to the configuration file is specified by environment variable configPath, defaults to /usr/wform/etc/form.cfg text files It specifies the path to the UNIX editor, the FORM parameter file; the format of the menu; storage How much variable; the key value of the special key.
(3) FORM parameter file: The path to the FORM parameter file is declared in the configuration file. Binary files store Dialog structure FORM data, the system read this file, press step. The parameter file of the screen of Mkform (Netform) is /usr/wform/etc/form.bin.sys
(4) Help information file: The path to help information file is specified by environment variable msgpath, default is /usr/wform/etc/form_msg.dat text file
(5) System Description File: System Description /usR/WForm/etc/readme.frm
(6) Library: /usr/wform/lib/libsetform.A is generated on Sco Unix OpenServer 5.0. /Usr/wform/lib/libnetform.A is generated (web version) on SCO UNIX OpenServer 5.0. (7) Demo routines: 1. Two form parameter files: /usr/wform/Data/demo.form /usr/wform/data/test.form 2. Menu Demo: / USR / WFORM / MENU / MENU /usr/wform/menu/Menu.ec /usr/wform/Menu/print.c/usr/wform/Menu/errhandle.c / usr / wform / menu / MKEFILE / USER / USER / WFORM / MENU / MKNET Link libnetform.a Makefile 3. Trading Demo: / USR / WFORM / Trade / Trade /usR/WFORM/Trade/trade.ec / usr / wform / trade / Makefile / USR / WFORM / Trade / MKNET Link Libnetform.A's Makefile 4 Two databases: /usr/wform/demo.exp /usr/wform/test.exp Description: Demo Menu, trade uses the database is TEST, the FORM parameter file is Test.Form.
three. Basic concept and use of the system
(1) Structure of FORM:
Typedef struct _item_st_ {char flag; // data type (or sign) char LEN; // Data length char seat_y; // Longitudinal SHORT SEAT_X; // Cross-coordinate CHAR FUN; // Form Embedded Function Pointer No. CHAR Field [41]; // Composite domain} item;
TYPEDEF STRUCT TAGOFDIALOG {Unsigned long form_id; // Trading number unsigned long link_form; // Connection trading char mode; // Direction method char key; // The number of Item * f; // Structure between Formon; Dialog;
(II) Basic concepts and uses 1. [Trading No.] (Dialog.form_ID) Form's number to index.
2. [Connection Transaction] (Dialog.Link_Form) Form The other form of the other FORM is called, this value is = 0, then it is not called.
3. [Drive mode] (Dialog.Mode) to determine the nature of the Form. M: Menu P: Print B: Browse E: End Dictionary Domain D: End Delete Window S: Screen Scroll C: Comprehensive Inquiry
4. [Code] (Dialog.key) Specifies the number of fields of query conditions, and its value corresponds to [order], and the serial number is less than the field equal to this value as the query article. Only valid for the query class Form.
The following is a structure (Dialog.f) of the Form, and the number of domains varies. 5. [Type] (Dialog.Item-> Flag)
Signifier Data Type SqldateType
(1) Input output item C, C ordinary string Char Char char char char char rate (Date of the string) CHAR Char A account (copy function on the string) Char char p password (no return CHAR Char G Option Char Char F Help Char Char D, D Date (From 1899.12.31 to the day of the day) long char m, M amount Double Money, FLOAT N, N value long intger, Smallint or above characters are input Item, lowercase characters are output. The table name and field name can be specified in the composite area, such as Table.field
(2) Miscellane T: Format B value domain check (check the previous value) b database (specified remote database), form Database @ Host L Title I menu entry X execute SQL statement - Connector | Rowing # 画 背景 背景 w
When you do not need to specify a table and field, the front four digits of the composite zone are stored in the coordinate, and the characters behind can be used as 'l', the coordinate = 0, and the header is used.
6. [Length] The length of the data is data length; the miscellaneous '|', '#' is representing the color. String data length <= 128. The length of the amount is <= 16: Length is the total number of digits before the decimal point and the number of digits, and the decimal point is set to two. Example: length = 14, the first 12 digits of the decimal point, 2 digits after the decimal point. The length of the amount> = 20: Position is the number of decimal points, and the number of digits before the decimal point before bit. Example: length = 125, the first 12 digits, 5 digits after the decimal point. Length of the amount> = 17AND <20 illegal.
7. [Coordinate] The two bits of the general Form are horizontal. The front is a longitudinal coordinate; the ordinate <24. There is a special specification for the coordinates of the browser: When the coordinate value is greater than 2499: The three digits are the abscissa, the front is a longitudinal coordinate. The maximum value of the abscissa 512. Example: Coordinate value 5150 denotes: horizontal coordinate = 150, ordinate = 5.
8. [Embed Function] Funfunction in Form, and then call a specific function when the program executes the domain, and the function pointer must initialize the value.
9. [Composite Domain] is the multi-purpose domain, which can be used as a write title, SQL statement, database table name, field name, and so on.
four. Instance explanation (omitted)
Fives. The function and application of this system
(1) The definition of the system:
Macro and FORM structure wform.h variable definition wvai.h nested function pointer fun.h
(2) Call of system functions:
1. Call of the menu: INT SETMENU (long ID) ID is the number of the main menu. The return value is the second few items that reflect the process of execution to the first few of the menus, and the Xiang see menu is made.
2. Form call: int setupform (long id, short wincode) ID is the number of the form. Wincode is the number of the window (0-9). If you use multiple windows when you use multiple windows, the window number must be different, otherwise it will overwrite. Return Value: 0 Cancel (ie press [ESCAPE] Exit) 1 Normal (ie press [ENTER] Exit)> 1 Press the hotkey or the custom key to return to some special keys and custom keys, that is, exit the FORM, the return value is as follows :
Key name return code
Directors DEBIT Loner key CREDIT forward key previoes Back button Next Hotkeys Hotkey Send key Finishkey custom key key value 2000
3. Other functions: (1) int msgbox (char Type, const char * fmt, ... / * args * /); Utue: Information Tips. The information length is less than 80 on the screen baseline display, otherwise it makes a Box. Type: msgerr (0) error msgProm (1) prompts Msgwait (3) warning with the Printf function.
(2) Void SetFormpa (Short Mode, Short Para); Utue: Setting the FORM parameter. MODE: Macro Numerical Winframe 0 Para: 1 Window Picture Box 0 Window Blessless Default 0 F_Color 1 Set ProspectSuper Default COLOR_WHITE (White) B_COLOR 2 Set Background Color Default Color_Black (Black) Concrete Color See
DisplayMode 3 PARA: 1 Pre-showing the original value 0 does not display the default 0
FIELDBOUND 4 Para: 1 Pair of input item Delined Detect "[...]" 0 Do not divide the default 1 DisplayBold 5 Para: 1 The character displayed is highlighted value 0 EnterDefault 6 Para: 1 input The item is only [Enter] and copy it into the original value. Default 0 LINETYPE 7 PARA: 1 Double Line 0 Single Line Default 1
Patternfront 8 PARA: 1 When runs the menu, the input character is the same as the first character of the menu option, can be selected and automatically entered. 0 Can't automatically enter. Default 1 (3) Void TouchForm (Short Wincode) Purpose: Repelling the covered form.
(4) INT SQLMSG (Short Sqlcode) Uses: Error message can be provided, and the program is executed (the line of the file). Usually used for SQL execution errors return. (5) Void Deldlgwin (Short Wincode) Used: Delete Form.
(6) Int Skipdomain (Short Step) Uses: Skip several domains (STEP). Used for embedded functions.
(7) Void Rfmtdate (Date i_date, char * fmt, char * result) Purpose: Turn Date in Informix into Char. Example: 1899.12.31 to 1999.12.4 The number of days is 36132. RFMTDATE (36132, "MM-DD -YYYYYYY, RESULT; RFMTDATE (36132, "MM-DD-YY", Result; Result = "12-04-98" RFMTDATE (36132, "Date: YYYY Year MM Month DD Day, Result; Result = "Date: December 4, 1998". (8) Void Rfmtdouble (Double Money, Char * FMT, Char * Result) Purpose: Transfer Double to CHAR. Example: Double A = -9030236.035; Rfmtdate (A, "-, ---, - 9.999", Result; Result = "-9, 030, 236.035"
(9) Char * DoubleTostr (Double Money, Const Char * FMT); Uses: Turn Double to Char Return (Char *).
(10) Void Printform (Short Wincode, Short Lin, Short Col, Char * FMT, ...); Uses: Convert characters to the Form.
(11) int Runfunction (int (* fun) (), char * msg); Utue: When running function fun, display information MSG at the bottom of the screen, jump characters '>' over a second. Example: See 280 rows of Menu.ec. Runfunction (DeleteTail, "Cleanup Data"); if the function deleteTail () is not in Menu.ec, you must declare extern int deleteTail ();
(12) Int callFunction (int (* fun) (), char * msg); Uses: With Runfunction (), no jump characters.
(13) Char * pntname (); Uses: Getting the device name of the printout. Get "/ dev / lp0" on the main control station, get the corresponding terminal number "/ dev / tty ???" (14) void Draws (Window * W, INT B_Y, INT) on the terminal e_x) Use: Picture at the specified window. The starting point coordinate (B_X, B_Y) endpoint coordinates (E_x, e_y) b_x = e_x draws straight line. B_Y = E_Y draws a horizon. B_x! = E_X B_Y! = E_Y painted rectangle.
(15) INT FORMPATH (CHAR * PATH); Utue: Call the function to set the path to the parameter of the Form, and the provincial path is set in the configuration file. (16) INSETFUN (N, FUN); Uses: Function Pointer Initialization. N is the number of the function pointer, FUN is a function name.
(3) Using the embedded function: Role: When the Form is called, the function called when the Form is executed. We will explain the use of the embedded function by menu.ec.
**** Note: The following is the 110 No. 110 in Test.form.
[Command] G [Traction No.] 110 [Connection Transaction] 0 [Drive Method] E [Code] 0 [Order] [Type] [Length] [Coordinate] [Embed Function] [Compound Domain] 0 C 3 1237 0 Bank.exchno 1 C 20 1337 0 Bank.officename 2 R 8 1537 1 3 T 0 0 0 Date Notice this day ago 4 a 7 1737 0 5 M 10 1937 0 6 B 0 0 0 7 I 0 0 0 62.50 8 i 0 0 0 999999.99 9 C 1 2137 0 10 B 0 0 0 11 I 0 0 [1, 4] 12 L 0 1226 2 Accept line 13 L 0 1326 0 linename: 14 l 0 1526 0 Document Date 15 L 0 1726 0 Code 16 L 0 1926 0 Gold 17 L 0 2126 0 League 18 L 0 2224 0 12 domains include embedded functions: 1, 2 is the number of function pointers, represents function checkdate (), Pattern (). Function pointer initialization: INSETFUN (1, checkdate); INSETFUN (2, pattern); see menu.e Rows 217,218.
When the program executes the second domain (ie the input date), the system calls the function checkdate () to check if the date is on the day before, if the date correct function returns 0, the program continues; if the date error function returns - 1. The program still stops in the second domain. If the function returns the -3 program to the 0th domain. Set Sn as the serial number executed. Ret = fun [n] (); SN = RET; you can return a value as needed, if the return value is 2, you will skip 2 domains. When the program executes the 11th domain, the system calls the function Pattern () to perform the credential pair.
(4) About the value of FORM:
Type.
Type variable name host variable name Form Editor Character (Char) Chars (N) $ INFSTRING [N] $ CN Integer (Long) Number [N] $ Number [N] $ NN Amount (Double) Money [ N] $ MONEY [N] $ mn Date (long) Date [N] $ DATE [N] $ DN Note: N is the sequence number chars (n) is macro, C language Chars (n), infstring [n] Available; in SQL language can only be used in infString [N], and cannot use macro Chars (N);
2. Configuration of the value.
According to the configuration dynamic application memory, the system is adjusted to adjust the system configuration (or modify form.cfg) to determine the number of values.
3. The order of values.
Use the example to explain:
[Order] [Type] [Length] [Coordinate] Corresponding variables
0 C 3 1237 Chars (0) 'C' Character Type 1 1 C 20 1337 Chars (1) 'C' Character Type 2 H 8 1537 Chars (2) 'h' Character Type 3 3 A 7 1737 Chars (3) 'A' Character type 4 M 10 1937 Money [0] 'M' 金 第 一代 1 5 B 0 0 Control class and variables unrelated 6 i 0 0 control class Unrelated to variables 7 I 0 0 Control class and variables unrelated 8 C 11 2120 Chars (4) 'c' character type Fifth appearance 9 b 0 0 control class and variable independent 10 i 0 0 control class and variable independent of 11 m 12 2126 Money [1] 'm' 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场 市场N 6 2170 Number [0] 'N' long integer first appearance
six. User environment using Form
The user can set the following environment variable (1) ConfigPath: The path to the configuration file of form. The path to the parameter for /usr/wform/etc/form.cfg form is set in the configuration file. The FormPath (Char * PATH) setting path can be called before the user's program is started. (2) Msgpath: Help item information file path. Default /usR/wform/etc/form_msg.dat (3) NetConfigfile: Communication configuration file, for this system's network version, customer and server, default to /usR/wform/etc/sys.net
Seven. Use of FORM generator (Mkform, Netform)
_. ---- ..__. '_ / -._ __ `` --._) | || ../// ./ / `--'_` -._ / (`-. / / // | / / - '' `` -._ | / `- .`` / / / / / /. ---.__. |` _ / `` `. -'_ / _ / / _ / | /// / _..- '/ /' -._ `/-._ / / ('//` -.` `( | _ '; `-.` `` `. / /` `-._ _.' | _`, '' _.- `'/ / --------` `- ~ - '`;` ~' `` `'' ._ //` // /. '`` `` --- .. -. ///' `/ / // //`. | ||. || ┏┏━━ 选择 ━ 选择 ━━━ ┓ /. || `` `- || V full screen editing _______ (0) /` || '; | T trading demo ___ (1); || '// M menu demonstration ___ (2) | _ || // [] D display system configuration _____ (3) / .``. .__.-; A adjustment system configuration _____ (3). '`` `` ``_ | _ | .- | S cleaning form _________ (5) /; P changed FORM parameter path _ (6); L registration registration _________ (7); E exit _____________ (8), '┗┗━━━ ━━━━━━━━┛┛
------------ Figure 10 -------------- (1) Usage Run MKFORM (or Netform) MKFORM: MKFORM -D Database -f FileName 1. Open the database: -d data can be omitted (not accessing the database). 2. Specify the FORM parameter file name: -f FileName, if you omit, press the path specified in the system configuration file. Mkform and Netform's main difference: MKFORM access to the remote database is the function of the Informix itself, that is, the SQLEXECD provides a service; Netform access database service (net_server) is written by the author, controlling data security, so When running Netform, you must start the NET_SERVER service program.
(2) Menu function
When you run MKFORM, you will appear in Figure 10. Here, the function of the menu is introduced one by one:
1. V full screen editing enters the editing of Form, custom programs. (Xiang you see a chapter about Form editing).
2. T Trading Demo program demonstrates programs driven by trading code.
3. M Trading Demo Program Demo the program driven by a menu.
4. D Display System Configuration (Figure 11) The path to the configuration file is specified by environment variable configpath, default is /usR/wform/etc/form.cfg
┏┏━━━━━━━━━ 系 配 配━━ 0━━━━━━┓┓┓ 0 0 0 参 参 Path: ../data/demo.form : / Usr / bin / vi 10. Number of characters (char): 50 3. Numeric (long) number: 10 10. 金 (double) Number: 10 5. Date type (DATE) Number: 8 10. Menu Maximum number of items: 100 菜 菜 格: (7. 2 8. 5) format: (9. 12 10.1) 11. Double button: 46 12. Quadruple: 47 13. 5 五: 42 14. Sixty-Length: 45 15. Ribbery: 3 16. Loiner Key: 4 10. Before: 91 18. Backward key: 93 19. Heat key: 26 20. Send button: 10,: [[[━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━━━━━━┛ ------------ Figure 11 -------------- 5. A Adjustment System Configuration Only the root user can adjust the system configuration .
Editing Command: Edit the text editing program called by Form.
Main menu format: (7. 2 8. 5) This configuration Description Main menu format is 2 lines, 5 columns. Select Section 7 to modify the number of rows, select Section 8 Modify the number of columns. Sub-menu format: (9. 12 10.1) This configuration Description Main menu format is 12 lines, 1 column. Select Item 9 to modify the number of lines, select Article 10 Modify the number of columns.
6. S cleaning FORM regular cleaning of FORMs that are invalidated and deleted. 7. P Change the Form Parameters Path The FORM Parameters The path is specified in MKForm or in the system configuration file, if you need other Form parameter files can be changed by this option. 8. L registration registration. 9. e exit the system.
(3) About Form Editing
In the menu in Fig. 10, a 0 item is selected, it will enter FIG. 12.
┏┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┓━━━━━━━━┓┓ ┓ [Command] ┏┏━━━ ━┓ [Connection Transaction] 0 [Drive Method] [Code] [Order] [Type Your Enter ___ (00) Function] [Compound Domain] (01)取 _ ___ (02) 2 Help ___ (03) 演 ___ (04) ▲ ▲ ___ (05)编 编 _ 存 盘 存 盘 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _备 0 delete ___ (10) ┛ ┗━━━━━┛ ┛ ┛ ┛ ┛ ┛ ┛ ▲ 16 10 ▲ 100 10 ▲
┗━━━━━━━━━━━━━━━━━━━━━━━━┛┛┛┛┛┛┛┛ --------- --- Figure 12 ------------ Distance Menu function in Figure 12:
1. A Enter the FORM editor of the system, the edited window is 20 items, a total of 5 screens; when the cursor goes to the last row, press ↓ button, you can turn it to the next screen.
2. e exit the editor.
3. Gets to enter the FORM parameters of this transaction to read the transaction number.
4. h Help Displays text /usR/wform/etc/readme.frm.
5. S Demonstrate the FORM Framework, Demo Enter, and Query of this Transaction.
6. U Restores the misused Form.
7. D Designed to use UNIX editing tools to initially customize Form. For details, please refer to the customization of FORM.
7. V Qian uses UNIX editing tools to set the parameters of the Form. For details, please refer to the editor of Form. 9. The W store will store the edited or modified Form into the file. The original form of the same number is invalid, so it needs to be cleaned up to the FORM. 10. f Single selection can separately select a specified FORM parameter, file name "./f ????", indicating the FORM number. Role: Some form functions is universal, movable to the FORM parameter file of other users. Immove method: Cat F ??? >> Other.form
11. D Delete the discarded Form to delete it.
(4) Customization of FORM: 1. Use the UNIX editing tool to initially customize Form. (1) Select the command V, enter the transaction number, (assuming the transaction number is 88). The system calls UNIX editing tools (such as VI), generating text / TMP / FORM88, written in text, as follows:
Number Text Belt 1 2 3 4 5 Record 6 7 8 Account: $ A12 9 10 Document Number: $ N6 11 Abstract: $ C10 13 14 Gold: $ M12
------------ Figure 13 --------------
The character after the '$' character is type, the number after the type is the length. After exiting the text store, the system screen is returned, and the system generates a structure of Dialog in the memory according to the text content and coordinates of each domain, as shown in Figure 14.
┏┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┓━━━━━━━━━┓┓┓ [━━━━━━━┓┓┓┓ [[━━━]] 8 88 [Connection Transaction] 0 [Drive mode] [Code] 0 [] [Type] [Length] [Coordinate] [Embedded Function] [Compound Domain] 0 A 12 739 0 1 N 6 939 0 2 c 0 0 437 0 5 l 0 730 0 account: 2 L 0 930 0 Document number: 0 1130 0 Summary: 0 0 0 0 0 10 0 0 10 0 10 0 0 0 14 0 0 16 16 16 16 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 19 0 0 0 ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┛ ------------ Figure 14 ------------ Use the command W storage, then use the command S to demonstrate, see Figure 15. If you are not satisfied with Form, you can modify or directly modify form until satisfaction.
┏┏━━━━━━━━━━━┓ ┓ 记 号 号 号 号 号 号 号 帐 号 号 号 号 号 号 号 号:: 号 号: [] 要: []金: [] ┗┗━━━━━━━━━━┛ ------------ Figure 15 ------------ (5) Editor of Form: Use UNIX editing is just the initial customization of Form, which can only define the title, data input, display field. For [Connection Transactions], [Drive Method], [Code], [Embed Functions], and menu, table name, field name, etc. of the database, require the editing function provided by the system or edit directly with VI.
Method 1 The editing function provided by the ____ system: (1) Use the command A to enter the domain that needs to be changed with the cursor keys. (2) Copy function of the row. Reproduce the N rows to the B line, the method is as follows: Move the cursor to the A line Press the F2 button, then press the number n to copy the number n, and then move the cursor to B Press the F2 key. Press twice in a row to copy a row in the original line. (3) The insertion function of the line. Press the [INSERT] button to increase a row of space lines. (4) Delete function of the line. The type of the deleted row is changed to space, and the row is eliminated. (5) Editing function of the composite domain. F1 key to right, [backspace] key to move left. Command Switch Key F3 or [Delete], X Delete Character, i inserts characters, function with VI.
Method 2 ___ utilize VI editing functions: (1) Use command V to enter, and then enter the FORM number. (2) If Form is new, the system generates a text with explanation and a certain format (see Figure 16), and you fill in editing. Such as Form already exists, the system generates a text with the original FORM parameter, modified by you.
[Trading No. 120 [Connection Transaction] 0 [Drive Method] B [Code] 3 [Type] [Length] [Coordinate] [Embed Function] [Compound Domain] ~~ Tip: The abscissa of the following values must be In the area of the field (in '[]'), it is invalid! The vacancy is zero ~~
------------ Figure 16 ------------
nine. Demonstration
The demonstration MENU, TRADE is the same; the shared database TEST, the FORM parameter file Test.form. How do you call this system function in TRADE.EC; you can also refer to ./Menu/makefile ,mknet ./trade/makefile ,mknet; ten. About the online version
The so-called network version is based on the original version, divides the program into a foreground program (interface control program) and background program (data server), the front desk involves the FORM of the data database, organizes into SQL statement through the network to the background, background Return SQL's execution results, as shown in Figure 16:
┏┏━━━┓ SQL statement to send the background ┏┏━━━━━━━┓┓ ┓ ┓ ─ ─ ─ ─ → → → → ....... .Tcp / ip ........... inland (net_server) ← ← - ────────────── ─ Server ┗┗━━━┛ query, update The result is returned to the front desk ┗┗━━━━━━━┛┛┛
------ Figure 16 -----
The core code of the query:
SELECT (INT TAG, CHAR * Command) {$ Char * SEL, STR [128]; $ Short Flag; $ DATE; $ Long Number, B_Count, J; $ Long PREC; $ long type; $ long scale; $ double $ char result [128]; int RET, OFFSET = 0; INT i = 0; char FMT [32], TAG
IF (DisplayFlag) Printf ("tag =% C / NSQL =% S / N", TAG, Command; RetPacket.txcode = SELECT
IF (tag == 'm') {// Multi-Query SEL = getField (Command, & Offset); if (Strlen (SEL) <2) goto exit1; tag = SEL [0];} else tag = tag; SEL = getField (Command, & Offset); if (tag == 'm') ChangeCMD (SEL); IF (Strlen (SEL) <10) goto exit1;
IF ((RET = Composebrowse (10, SEL)) <0) {sqlerrhandle (sqlcode, select); goto exit0;} retPacket.txcode = select;
$ get descriptor 'browsdesdesc': b_count = count; if (sqlcode) {sqlerrhandle (sqlcode, select); goto exit0;
$ fetch browse using sql descriptor 'browsdesc'; if (sqlcode) {structure (RetPacket.Data, "SELECT Error |"); sqlerrhandle (Sqlcode, SELECT); goto exit0;}
For (j = 1; j <= b_count; j ) {$ get descriptor 'browsdesc' value $ j $ prec = precision, / * money, decimal * / $ scale = scale, / * Money, Decimal * / $ type = Type; if (Sqlcode) {structure (retPacket.data, "select error |"); sqlerrhandle (sqlcode, select); goto exit0;} switch (type) {copy sqlflofloat: Case Sqlsmfloat: Case Sqldecimal: Case Sqlmoney: IF PREC) SPRINTF (FMT, "% S% D.% DF / 0", "%", prec 1, scale); Else Strcpy (FMT, "% F"); $ get descriptor 'browsdesc' value $ j $ Money = Data; Sprintf (Result, FMT, Money); if (Sqlcode == Dataisnull) Result [0] = 0; Break; Default: $ GET Descriptor 'browsdesc' value $ j $ results = data;} // switch
Deltailspace (Result);
IF (sqlcode == dataisnull) sqlcode = 0;
IF (SQLCODE) {structure (retPacket.data, "select error |"); sqlerrhandle (sqlcode, select); goto exit0;}
STRCAT (RETPACKET.DATA, RESULT); strcat (retPacket.data, "|");} // for if (displayflag) PUTS (RetPacket.Data);
EXIT0: $ close Browse; $ free browse; $ deallocate descriptor 'browsdesc'; exit1: return true;}
(1) The role of the online version: enhances security. Informix can access remote databases, but must establish a peer-to-peer relationship. This version does not have to establish a peer-to-peer relationship, overcome this weakness.
(2) Usage of the online version: 1. Network communication uses the TCP / IP protocol. 2. Before, the background program can also be on the same machine. 3. Form customization, function and function constant. 4. Link Library: /usr/wform/lib/libnetform.a. 5. Communication configuration file: $ home / etc / sys.net:
(1) Database Name: Setting [Database] Database = Mobile (2) Background Machine Name: Before, the background must be consistent. / etc / hosts exists, or you can write the IP address directly. [ServerHost] ServerHost = Save01
(3) Port number: Before, the background must be consistent. Netform TCP Port] NetFormTcpport = 8168
(4) Socket timeout alarm time (seconds), independent value 60 [Socket READ & WRITE TIME OUT (SOCKET READ & WRITE TIME OUT (SOCKETTIMEOUT = 35 (5) Query timeout alarm time (second), the value of 60, only for the front desk . [Wgetch time out (s)] wgetchtimeout = 30
(6) Track mark, only set to the front desk, 0 mask, 1 open. Trace file: $ homen / run / trace [trace flag] traceflag = 0
(7) Connect timeout alarm time (seconds) is only set to the front desk. [Company Server Connect Time Out (s)] ConnectTimeout = 8
(8) The maximum number of the fork service is simultaneously in the process, only the background. [MAX user Number] usernum = 10
(9) Display some of the data accepted and transmitted. 0 mask, 1 open [Display Server Data Flag] DisplayFlag = 1
6. Address Book File: $ HOME / etc / hosts.equ Set the IP address of the front desk machine that allows access to the database, unrecorded machines cannot be accessed. Setting method: (1) Add All.hosts to all customers, open to all customers. (2) Add a network segment address (such as 13.7.5) to the file, open to the network segment. (3) Add a full client IP address (such as 12.17.23.76) to open it.
7. Start of the server: NET_SERVER
8. The server's stop: NET_SERVER STOP
9. Return Value: When SQLCode> -10 is the definition of this system, the meaning is as follows:
-1 Receipt data package error: such as timeout. -2 Denial Service: Address Book Bless the Number IP Address-4 Service Process exceeds the number of qualified.