General string expression compiler forcal v7.0 programming guide

xiaoxiao2021-04-10  587

Welcome to visit the main math software main station I want to send me a message on the 6TO23 station: 9CBS Blog Baidu Space Forcal.dll V7.0 Programming Guide Directory

1 Output Function 2 Simple Calculation 3 Forcal Secondary Function Design 4 Forcal Basic Uses 5 FORCAL Save and Retrieve Data FORCAL Output Dynamic Library Functions with Win32 Standard Function Call Mode (STDCALL Call Protocol), available for C / C , VB, Delphi, Fortran and other programs are used. In addition to GETRUNERR (), TestruneR () and StrunerR () three functions, the remaining functions can only be used in single-threading (not allowing two and more than two threads to run these functions at the same time), in designing multi-threaded applications Pay attention to this. In the following description, Fcint is defined as long integer long, namely: typedef long fcint; 1 output function [Back to top] 1.1 version information function const char * _stdcall force (void); 1.2 Initial Bool _stdcall Initirtal (void " Before using Forcal, it must be initialized with this function. Returns true when initialization is successful, otherwise returns false. The force can be reinitialized using this function at any time, so that the force restores the state when the function is called for the first time. 1.3 Release Forcal Void_stdcall Freeforcal (Void); as long as the Forcal dynamic library function is used, the dynamic library must be released with this function before uninstalling the dynamic library. 1.4 Get the Forcal Run Error Void_stdcall getRuNerr (int & errcode); Fortype returns the type of running error. Fortype = 0: No running error; Fortype = 1: Integer expression run error; fortype = 2: Real expression run error; fortype = 3: Formy expression run error; Fortype = Other values: Other types of operation errors. Funname: Returns the wrong function name. Errcode: Returns the error code. Forcal runs the first run error when running. This function is usually used before and after compiling expressions and performing expressions. After using this function, Forcal will return to a wrong state. Use this function after compiling and performing expressions, is to detect an operation error. The reason why it is necessary to use this function before compiling and perform expressions (before compiling and performing expressions, it should be guaranteed to run errors. If it is confident, it is also possible to use the function), because the function can restore force to Wornless; of course, it is also possible to use the setRunerR () function to be set directly to a wrong state. 1.5 Test forcal Run Error INT _STDCALL TESTRUNERR (Void); This function returns the type of Forcal running error, indicating no errors when returning 0. This function is only tested whether there is a run error and does not change the status of the error. This function is usually used in the secondary function design. 1.6 Set Forcal Running Error VOID _STDCALL SETRUNERR (int Fortype, CHAR * FUNNAME, INTYERRCODE); Fortype: Set the type of running error.

Fortype = 1: Integer expression run error; Fortype = 2: Real expression run error; fortype = 3: complex expression run error; Fortype = Other values: Other types of running errors. Funname: Set the function name of an error. Errcode: Set the error code. When designing a custom secondary function, you can use this function to set Forcal running errors. Since FORCAL only saves the first run error, before the settings, the TestrUNERR (STDTESTRUNERR) function test does have an operation error, if there is no appearance, setup, otherwise, it is not possible. Forcal allows another thread to modify the error status of the runtime to exit the Forcal run, so you can use the setRUNERR () function to set up a run error in other threads. 1.7 Compiling Real Expression INT _STDCALL Realcom (Char * Forstr, Fcint NModule, Void * & HFOR, FCINT & NPARA, DOUBLE * & PARA, FCINT & Errbegin, Fcint & Errend); Forstr: String Expressions. NMODULE: Module number. HFOR: Expression handle, identify an expression, use the parameter when calculating the value of the expression. This parameter must be variables and cannot be constant. NPARA: This parameter must be variables and cannot be constant. This parameter returns the number of self-variables of the expression. When NPARA = -1 indicates that there are 0 arguments. When NPARA = 0 indicates that there is a self-variable, two independent variables are indicated when npara = 1, and push it according to the secondary. PARA: This parameter must be variables and cannot be constant. This parameter returns an array pointer for inputting an argument. This parameter is used when calculating the value of the expression. Of course, you can use this parameter to enter an argument with your own array. Errbegin: This parameter must be variables and cannot be constant. This parameter returns an error initial location. Errend: This parameter must be variables and cannot be constant. This parameter returns the end position of the error. This function returns to compile code. When the return value is 0, it means no errors, when other values ​​are returned, indicating that there is a compilation error, and the error position is determined by Errbegin and Errend.

The meaning of compiling error codes is as follows: -1: In the shared version, the length of the compilation expression is limited! 0: There is no mistake, compiled success! 1: Memory allocation failed! 2: Brackets are not pair! 3: No expression after (after the equal sign)! 4: I can't use i as a parameter in the complex expression! 5: String transfi character error! 6: The string is invalid, that is, "..." does not match! 7: Do not recognize characters! 8: Expression name definition error! 9: Unrecognizable independent variables, can only begin with letters or downline lines! 10: Unrecognizable self-variable definition method, "(,:,:,:,:, ...)" Too many colons! 11: Definition of the variable! 12: Continue () function can only have 0 parameters! 13: I can only use the Continue function in While, untricil! 14: BREAK () function can only have 0 parameters! 15: I can only use the BREAK function in While, UnTil! 16: If, while, unsil, the number of parameters in WHICH is at least 2! 17: Digital errors in the expression! 18: & Unco-access address operator can only be used for individual variables! 19: Single Operator , - Error! 20: There is no number in parentheses! 21: Single Operators , - ,! Errors! 22: Assignment "=" error! 23: Incorrect operation or other grammatical error! 24: Do not identify variable name! 25: Unrecognizable function name! 26: The first-class function can only have a parameter! 27: The secondary function parameters do not match! 28: *** Undefined ***! 29: (Module) Expression has a heavy name! 30: *** Undefined ***! 31: *** Undefined ***! 32: Parameter does not match when calling integer expressions! 33: The parameter does not match when calling the real expression! 34: The parameter does not match when calling the complex expression! 35: Self-variable rename! 36: Exit due to the detection of the error! Usually use the setRuneRR () function or getRunerR () function before compiling, it is used to detect run errors after compiling. Error settings for other threads allow forcal to exit the long compilation process, return to the error code 36. FORCAL supports modular compilation of expressions. When compiling expressions with Forcal, you want to specify a module number, and the module number is identified by an integer. In Forcal, one module consists of one or more expressions. The module uses an integer identifier, the integer is negative, as long as the absolute value is equal, it belongs to the same module. The module name is typically represented by a positive integer.

The module has two types, namely the main module (0 # module), and a normal module (module of other labels). In the same module, the module number is negative expression can only access (ie, call) the expression of this module, and only the expression of this module can be accessed, the module number is positive expression, which can be accessed within this module. Expression, you can also access other modules (except for main modules) all module numbers are positive expressions. This specification of Forcal, an expression with a negative module number is invisible in other modules, and it has played a role of information protection. Forcal stipulates that the main module can access all modules in this module or all modules in other modules. Therefore, the main module is often used in the main program. 1.8 Calculate the value of the real expression Double _stdcall realcal (Void * HFOR, DOUBLE * D); calculate the real estimate HFOR, HFOR is the handle of real expression; the array D is stored in the array D. The parameter D cannot be NULL. Variable parameters can be stored in any array. If the expression is an expression in a simple module, the argument in the array d remains unchanged during the function call, otherwise the self-variable may be re-assigned. Usually use the setRuneR () function or getRunerr () function before calculation, and then detect operation errors after calculating the GetRunerR (). 1.9 Compiling Integer Expressions INT _STDCALL INTCOM (Char * Forstr, Fcint NModule, Void * & HFOR, FCINT & NPARA, LONG * & PARA, FCINT & ERRBEGIN, FCINT & ERREND); FORSTR: String Expressions. NMODULE: Module number. HFOR: Expression handle, identify an expression, use the parameter when calculating the value of the expression. This parameter must be variables and cannot be constant. NPARA: This parameter must be variables and cannot be constant. This parameter returns the number of self-variables of the expression. When NPARA = -1 indicates that there are 0 arguments. When NPARA = 0 indicates that there is a self-variable, two independent variables are indicated when npara = 1, and push it according to the secondary. PARA: This parameter must be variables and cannot be constant. This parameter returns an array pointer for inputting an argument. This parameter is used when calculating the value of the expression. Of course, you can use this parameter to enter an argument with your own array. Errbegin: This parameter must be variables and cannot be constant. This parameter returns an error initial location. Errend: This parameter must be variables and cannot be constant. This parameter returns the end position of the error. This function returns to compile code. When the return value is 0, it means no errors, when other values ​​are returned, indicating that there is a compilation error, and the error position is determined by Errbegin and Errend. Usually use the setRuneRR () function or getRunerR () function before compiling, it is used to detect run errors after compiling. Other refer to the instructions in "1.7 Compile Real Expression". 1.10 Calculate the value of the integer expression long _stdcall Intcal (Void * HFOR, long * d); calculate an integer expression HFOR, HFOR is an integer expression handle; the array D is stored in the array D, and the parameter D cannot be NULL. Variable parameters can be stored in any array.

If the expression is an expression in a simple module, the argument in the array d remains unchanged during the function call, otherwise the self-variable may be re-assigned. Usually use the setRuneR () function or getRunerr () function before calculation, and then detect operation errors after calculating the GetRunerR (). 1.11 Compiling complex expressions INT _STDCALL Complexcom (Char * FCINT NMODULE, VOID * & HFOR, FCINT & NPARA, _COMPLEX * & PARA, FCINT & Errbegin, Fcint & Errend); Forstr: String Expressions. NMODULE: Module number. HFOR: Expression handle, identify an expression, use the parameter when calculating the value of the expression. This parameter must be variables and cannot be constant. NPARA: This parameter must be variables and cannot be constant. This parameter returns the number of self-variables of the expression. When NPARA = -1 indicates that there are 0 arguments. When NPARA = 0 indicates that there is a self-variable, two independent variables are indicated when npara = 1, and push it according to the secondary. PARA: This parameter must be variables and cannot be constant. This parameter returns an array pointer for inputting an argument. This parameter is used when calculating the value of the expression. Of course, you can use this parameter to enter an argument with your own array. Errbegin: This parameter must be variables and cannot be constant. This parameter returns an error initial location. Errend: This parameter must be variables and cannot be constant. This parameter returns the end position of the error. This function returns to compile code. When the return value is 0, it means no errors, when other values ​​are returned, indicating that there is a compilation error, and the error position is determined by Errbegin and Errend. Usually use the setRuneRR () function or getRunerR () function before compiling, it is used to detect run errors after compiling. Other refer to the instructions in "1.7 Compile Real Expression". 1.12 Calculate the value of the complex expression _Complex _ HFOR, _COMPLEX * D); calculate the complex expression HFOR, HFOR is the handle of the complex expression; the array D is stored in the array d, the parameter D cannot be NULL. Variable parameters can be stored in any array. If the expression is an expression in a simple module, the argument in the array d remains unchanged during the function call, otherwise the self-variable may be re-assigned. Usually use the setRuneR () function or getRunerr () function before calculation, and then detect operation errors after calculating the GetRunerR (). 1.13 Setting the external secondary function int _stdcall setFunction (int funType, char * funname, void * fun, fcint paranum); Funtype: Secondary function type. You can only take the key_intfunction, key_realfunction, key_complexfunction (identifier plurality function), Key_ComplexFunction. The values ​​of these three identifiers are defined in header file forcal7.h. Funname: The secondary function name is to comply with the naming of the Forcal identifier. Fun: Secondary Function Pointer.

Integer, real, complex secondary functions are shown in the format: long intFun (Fcint M, Long * Para, Void * HFOR); // force standard integer secondary function; Double RealFun (Fcint M, Double * Para, void * hfor; // force standard real secondary function; _complex complexfun (fcint m, _complex * para, void * HFOR); // force standard plural secondary function; where M is transmitted to this function The number of parameters, -1 indicates that there are 0 arguments, and 0 indicates that there is one independent variable, and it is pushed according to the class. PARA is an array of storage parameters. HFOR is a expression handle that calls the function (not the expression handle returned when compiling the expression). In the Forcal expression, the general form of the function is Funname (X1, X2, ..., XN). ParaNum: Store the number of self-variables of the secondary function. The corresponding number of array paranum stores the number of variables of each function, where -2 indicates that there is a number of indeterfied arguments, and -1 indicates that there are 0 arguments, and 0 indicates that there is a self-variable, and it is pushed. The meaning of the function return value is as follows: 0: Set success. 1: This function already exists. 2: Memory allocation failed. 3: You can't use an empty string as a function name. 4: Illegal secondary function type identity. Example: Double _stdcall ASD (Fcint, Double *, Void *); // Custom Real Two Function; SetFunction (Key_RealFunction, "ASD", ASD, 2); // Set real secondary function; Note: 1 When designing the secondary function, you usually report to the Forfal Run error with SETRUNERR (...). 2, usually the setting of the secondary function immediately after initialization forcal. 3. Designing the secondary function must use the _stdcall call protocol (Win32 standard function call mode). 1.14 Set constant int _stdcall setConst (int Consttype, Char * constname, void * constvalue); ConstType: constant type. You can only take Key_InTconst (identify integer constant), Key_RealConst, key_complexconst (identifier multiple constant). The values ​​of these three identifiers are defined in header file forcal7.h. Conststr: Constant name, comply with naming regulations for the Forcal identifier. ConstValue: Pointer to the value of the constant. The meaning of the function return value is as follows: 0: Set success. 1: This constant already exists. 2: Memory allocation failed. 3: You cannot use an empty string as a constant name. 4: Illegal constant type logo.

For example: Double * pi = 3.14; // Set the value of constant; setConst (key_realconst, "pi", pi); // Set constant; 1.15 Delete constant or secondary function void _stdcall deleteConstorfunction (int type, char * name); TYPE: constant or function type. Can only take Key_InTconst, Key_RealConst, key_complexconst, key_intfunction, key_realfunction, key_complexfunction (identification number 2) function). The value of these six identifiers is defined in header file forcal7.h. Name: Constant or function name, compliant naming regulations for the Forcal identifier. 1.16 Judging whether an expression is effective BOOL _STDCALL ISFOR (Char * ForType, Fcint NModule, Void * HFOR, VOID * Para, Fcint Parenum); forname: The name of the expression. Fortype: The type of expression. You can only take key_intfor (identify integer expressions), key_realfor, key_complexfor (identifier plural expression). The values ​​of these three identifiers are defined in header file forcal7.h. NMODULE: The module to which the expression belongs. HFOR: Expression handle, the handle is the same as the type of expression handle, which can be used, can be used for the calculation of the expression. PARA: Store an array pointer of an expression of an argument. ParaNum: The number of expressive arguments. This function returns TRUE when the expression is valid, returning false is not a valid expression. 1.17 Get an expression information BOOL _STDCALL GETFOR (Char * Forname, INT Forty, Void * HFOR, FCINT & NMODULE, VOID * & MYFOR, VOID * & PARA, FCINT & PARENUM); Forname: The name of the expression of the query. Fortype: The type of expression of the query. You can only take key_intfor (identify integer expressions), key_realfor, key_complexfor (identifier plural expression). The values ​​of these three identifiers are defined in header file forcal7.h. HFOR: Expression handle obtained from the secondary function. You cannot use the expression handle obtained by the compilation expression. NMODULE: This parameter must be variables and cannot be constant. This parameter returns a module to which the expression belongs. MyFOR: This parameter must be variables and cannot be constant. This parameter returns an expression handle that is the same as the type of expression handle obtained by the compilation expression, which can be used for the calculation of the expression. PARA: This parameter must be variables and cannot be constant. This parameter returns an array pointer that stores an expressible argument and can be used to enter an argument. ParaNum: This parameter must be variables and cannot be constant. This parameter returns the number of expressible arguments.

When paraNum = -1 indicates that there is a variable when paraNum = 0 indicates that there is a self-variable when paraNum = 1 indicates that there is two arguments, and it is pushed. This function returns to True, the query is successful, otherwise returns false. Note: This function can only be used in the secondary function. 1.18 Judging whether the index of the expression is re-assaped BOOL _STDCALL PARAMODIFY (INT FORTYPE, VOID * VFOR); Fortype: The type of expression of the query. You can only take key_intfor (identify integer expressions), key_realfor, key_complexfor (identifier plural expression). The values ​​of these three identifiers are defined in header file forcal7.h. VFOR: The expression handle obtained when compiling the expression. If the index value of the expression (still assigning the local variable or global variable), the function returns true, otherwise false. In programming, sometimes if you do not re-assign the argument in the expression, you can simplify the program's design, and speed up the execution speed of the program. This requirement to express it can be judged by this function. 1.19 Getting string void _stdcall getforstr (Void * HFOR, CHAR * & FORSTR, FCINT & STRMAX); HFOR: Expression handle obtained from the secondary function. You cannot use the expression handle obtained by the compilation expression. Forstr: This parameter must be variables and cannot be constant. This parameter returns a string pointer, and the first address of all strings in the expression can be added to the pointer to get an integer. All strings in the expression are continuously stored. Strmax: This parameter must be variables and cannot be constant. This parameter returns the total length of all strings in the expression. Note: This function can only be used in the secondary function. 1.20 Get array information BOOL _STDCALL GETARRAY (int ArrayType, Char * ArrayName, Void * & Array, long & arraymax); ArrayType: Array Type. You can only take Key_Intarray, key_realarray (identify one dimensional number), key_complexarray, key_str (identify one dimensional character array, namely: string). The values ​​of these three identifiers are defined in header file forcal7.h. ArrayName: Array name. Array: This parameter must be variables and cannot be constant. This parameter returns an array pointer. ArrayMax: This parameter must be variables and cannot be constant. This parameter returns the length of the array. 1.21 Delete an expression VOID _STDCALL DeleteFor (int fortepe, void * hfter); Fortype: Expression type. You can only take key_intfor (identify integer expressions), key_realfor, key_complexfor (identifier plural expression). The values ​​of these three identifiers are defined in header file forcal7.h. HFOR: Expression handle, the handle is a handle obtained when compiling expressions.

1.22 Insert a key INT _STDCALL INSERTKEY (CHAR * KeyStr, INT Keytype, Void * KeyValue, Void (_stdcall * delkey) (VOID * & NOWKEY); Keystr: key name. not case sensitive. KeyType: The type of user custom key. The minimum value of this type is fc_key_user. The convention saves some special data with fc_key_user, as a channel between multiple functions, threads, dynamic libraries, and the like. Fc_key_user is defined in header file forcal7.h. KeyValue: key value. User-defined, identify a certain data type. Delkey: Delete the function pointer of the key value. This function is defined by the user, but is called by Forcal, that is: DELKEY (KeyValue); Remove KeyValue. This parameter can be set to NULL if it is not required to delete the key value. NowKey: This parameter must be variables and cannot be constant. If there is a key to the same type, if nowKey = 0, the key value is not updated, the parameter returns the existing key value; if nowKey! = 0, the key value is updated. The meaning of the function return value is as follows: 0: Insert success. 1: This button already exists. If nowKey = 0, the key value is not updated, returns the existing key value by the parameter nowKey; if nowKey! = 0, the key value is updated. 2: Memory allocation failed. 3: You cannot use a null string as the name of the key. 1.23 Find a key void * _stdcall searchkey (CHAR * KeyStr, int keyType); keyStr: key name. not case sensitive. KeyType: The type of user custom key. The minimum value of this type is fc_key_user. Fc_key_user is defined in header file forcal7.h. If the lookup is successful, the function returns the pointer of the key value, otherwise returns false. 1.24 Delete a key void _stdcall deleteKey (Char * keyStr, int keyType); keyStr: key name. not case sensitive. KeyType: The type of user custom key. The minimum value of this type is fc_key_user. Fc_key_user is defined in header file forcal7.h. 2 Simple calculation [Back to top] 2. Use forcal to make simple integer calculations 1, initialize Forcal; 2, use intcom (Char * Forstr, Fcint NModule, Void * & HFOR, FCINT & NPARA, LONG * & PARA, FCINT & ERRBEGIN , Fcint & Errend) Compiling the expression, the module number nModule is set according to the actual situation; 3. Calculate the expression with INTCAL (VOID * HFOR, Long * D);

2.2 Using Forcal to perform simple real calculations 1, use initforcal () to initialize Forcal; 2, compile expressions with Realcom (Char * Forstr, Fcint NModule, Void * & Hfor, Fcint & Npa, Double * & Para, Fcint & Errbegin, Fcint & Errend), The module number nModule is set according to the actual situation; 3. Calculate the expression with Realcal (Void * HFOR, Double * D); 4. Release Forcal with FreeForcal (). 2.3 Simple complex calculations using Forcal 1, initialize forcal; 2, compiling expressions with Complexcom (Char * Forstr, Fcint NModule, Void * & Hfor, Fcint & Npa, _Complex * & Para, Fcint & Erbegin, Fcint & Errend), The module number nModule is set according to the actual situation; 3. Calculate the expression with complexcal (Void * HFOR, _COMPLEX * D); 4. Release Forcal with FreeForcal (). 2.4 Using Forcal for simple implementation, integers and plural calculations 1, initialize forcal with initforcal (). 2, compiling expressions with intcom (Char * Forstr, Fcint NModule, Void * & HFOR, FCINT & NPARA, FCINT & PARA, FCINT & ERRBEGIN, FCINT & Errend), module number nModule sets according to actual conditions; use realcom (char * Forstr, Fcint NModule, Void * & HFOR, FCINT & NPARA, DOUBLE * & PARA, FCINT & NPARA, FCINT & Errend Compile Real Expression, Module NMODULE sets according to the actual situation; with Complexcom (Char * Forstr, Fcint NModule, Void * & HFOR, FCINT & npara, _COMPLEX * & PARA, FCINT & Errbegin, Fcint & Errend) Compile complex expression, module number nModule sets according to the actual situation; * HFOR, DOUBLE * D) Calculate real estimates; calculate complex expressions with complexcal; 4, release forcal with Freeforcal (). 3 Forcal Secondary Function Design [Back to top] Description, plural, integer secondary function design is similar to this. The general form of the secondary function is: Double _stdcall fun2name (Fcint N, Double * D, Void * HFOR); accordingly, the use form of the secondary function in the expression is: fun2name (x1, x2, ... .. ., XN) A number of arguments X1, X2, ..., XN; integer n, indicate the number of arguments, and the number of sizes is reduced by one.

HFOR is a handle of the expression of the secondary function transferred by Forcal, the handle is different from the handle obtained by the compilation expression. More information can be obtained by the handle. The following is the Forcal output function and precautions that may be used in the secondary function design: 1. Get the character string in the expression with the getForstr (...) function. This function can only be used inside the secondary function. 2. Use the getfor (...) function to obtain individual expressions and calculate. This function can only be used inside the secondary function. 3, get the Forcal array with GetArray (...) and operate. 4. Test if there is a run error with TestruneRR (Void). Since the Forcal allows another thread to modify the error status of the runtime to exit the Forcal run, in the secondary function design, in the cyclic body that may cause infinity loops, you should use the TestrUNERR () function to detect running errors, if any errors are detected In order to exit the secondary function. 5. Set the running error of the external function with SETRUNERR (...). 4 Forcal Basic Usage [Back to top] Although the usage of Forcal expressions can be very flexible, the following two usage may be the most basic. 4.1 Dynamic Using String Expressions During operation, dynamically use string expressions and calculate. For example, you need to calculate the value of the string mathematical expression, or perform certain commands, and the like. In this approach, for a specific operation, it is only written using Forcal when needed, while other code is written in advanced languages ​​such as C / C or Fortran. The numerical calculation procedure obtained with this method has a speed of about 50% of C / C or FORTRAN execution speed. However, the program can be generated by the high-level language compiler, and it is as convenient to use Matlab and Mathematics. 4.2 Perform an expression in order to perform an expression in order this is one way to program for Forcal. Expressions in the program file are separated by separators (usually used by semicolons ";"), compiling each expression in one order, and after compiling, the various expressions are sequentially executed in sequence. No matter which use method, check Forcal run error before and after compiling expressions and calculation expressions. Forcal always remembers the compiled expression, which makes the expression of the same name will no longer be compiled unless you release the space occupied by the expression. You can release the space occupied by the DeleteFor (...) function. If you use an initialization function initforcal (), you will be deleted along with all registered secondary functions, constants, applications, and all custom data to register. 5 Save and retrieve data with Forcal [Back to top] forcal saves and retrieves data information with multi-key-value string, with high storage efficiency and fast query speed. Users can save customized data information into the key tree and integrate with Forcal. Users can insert, query and delete data information in the key tree through INSERTKEY (...), SearchKey (...), DeleteKey (...). Copyright © Forcal Mathematics Software 2002-2007, All rights reserved E-mail: forcal@sina.com QQ: 630715621 Recent Update:

January 10, 2007

转载请注明原文地址:https://www.9cbs.com/read-133485.html

New Post(0)