Showing posts with label infobasic command. Show all posts
Showing posts with label infobasic command. Show all posts

Friday, May 6, 2011

jBase Infobasic Command DEL

Use the DEL statement to remove a specified element of a dynamic array.

Command Syntax

DEL variable

Syntax Elements

The variable can be any previously assigned variable or matrix element. The expressions must evaluate to a numeric value or a runtime error will occur.
expression1 specifies the field in the array to operate upon and must be present.
expression2 specifies the multivalue within the field to operate upon and is an optional parameter.
expression3 is optionally present when expression2 has been included. It specifies which subvalue to delete within the specified multivalue.

Notes

Truncates non-integer values for any of the expressions to integers.

Ignores invalid numeric values for the expressions without warning.

The command operates within the scope specified, i.e. if specifying only a field then it deletes the entire field (including its multivalues and subvalues). If specifying a subvalue, then it deletes only the subvalue leaving its parent multivalue and field intact.

Examples

FOR I = 1 TO 20
Numbers<I> = I ;*//generate numbers
NEXT I
FOR I = 19 TO 1 STEP –2
DEL Numbers<I> ;*//remove odd numbers
NEXT I
Continue Reading...

Thursday, April 28, 2011

jBase Infobasic Command DEFFUN

jbase tutorial
Use the DEFFUN statement to declare an external jBASE BASIC function to the jBASE BASIC compiler and optionally define its arguments. Use DEFFUN in the program that calls the function.

Command Syntax

DEFFUN FuncName ({ {MAT} Argument1, {MAT} Argument2...})

Syntax Elements

FuncName is the name used to define the function. It must be the same as the source file name.
Argument specifies a value passed to the function by the calling program. To pass an array, the keyword you must use the MAT before the argument name. These parameters are optional (as indicated in the Command Syntax) but can be specified for clarity. Note that if the arguments are not initialized somewhere in the program you will receive a compiler warning.

Notes

The DEFFUN statement identifies a user-written function to the jBASE BASIC compiler, which must be present in each program that calls the function, before the function is called. A hidden argument is passed to the function so that a value can be returned to the calling program. The return value is set in the function using the RETURN (value) statement. If the RETURN statement specifies no value then the function returns an empty string.

Example 1

DEFFUN Add()
A = 10
B = 20
sum = Add(A, B)
PRINT sum
X = RND (42)
Y = RND(24
)
PRINT Add(X, Y)
FUNCTION Add(operand1, operand2)
result = operand1 + operand2
RETURN(result)
Call standard UNIX functions directly by declaring them with the DEFC statement according to their parameter requirements. However, they may only be called directly providing they return one of the type int or float/double or that the return type may be ignored.

Example 2

DEFC INT getpid()
CRT "Process id =":getpid()
Continue Reading...

Tuesday, April 26, 2011

jBase Infobasic Command DEFCE

With jBASE 4.1 the DEFCE statement should be used, rather than the DEFC statement, for calling external C programs, which are pure ‘C’ code and do not use the jBASE library macro’s and functions. The DEFCE statement assumes that the C functions will need to manipulate jBASE BASIC variables and hence will also require the thread data pointer. As such, all C functions require recoding to include the data pointer as an argument to the C function. The location of the data pointer argument depends upon the function return type.

Example

For C functions that do not require jBASE functions use the DEFCE statement, however the passing arguments can only be of type INT, FLOAT and STRING.
DEFCE INT MYFUNC3(INT)

INT32 MYFUNC3(INT32 Count)
{
INT32 Result;
….
return Result;
}

Example 2

#include 
#include 
#ifdef DPSTRUCT_DEF
#define JBASEDP DPSTRUCT *dp,
#else
#define JBASEDP
#endif

VAR *MyString(VAR *Result, JBASEDP VAR *VarPtr)
{
char *Ptr;
assert(dp != NULL);
Ptr = (char *) CONV_SFB(VarPtr);
printf("MyString: %s - %d\n", Ptr, strlen(Ptr) );
STORE_VBI(Result, strlen(Ptr) );
return(Result);
}
INT32 MyCalc(INT32 Value1, INT32 Value2)
{
INT32 Result;
Result = (Value1 / Value2);
printf("MyCalc: %d\n", Result);
return(Result);
}
Continue Reading...

Sunday, April 17, 2011

jBase Infobasic Function DEFC

Use the DEFC statement to declare an external C function to the jBASE BASIC compiler, define its arguments, and return types.

Command Syntax

DEFC {FuncType} FuncName ({ArgType {, ArgType ...}})

Syntax Elements

FuncType and ArgType are selected from one of INT, FLOAT or VAR. FuncType specifies the type of result that the function will return. Assumes INT if FuncType is omitted. The optional list of ArgTypes specifies the argument types that the C function will expect. The compiler must know this in advance, as it will automatically perform type conversions on these arguments.

Notes

Compile a DEFC for each C function before making any reference to it else the compiler will not recognize the function name.
The function is called in the same manner, as it would be in a C program, which means it can be used as if it was an intrinsic function of the jBASE BASIC language and therefore returns a value. However,specifying it as a standalone function call causes the compiler to generate code that ignores any returned values.
When passing jBASE BASIC variables to a C function, you must utilize the predefined macros to access the various data types it contains. C functions are particularly useful for increasing the performance of tight loops that perform specific functions. The jBASE BASIC compiler must cater for any eventuality within a loop (such as the controlling variable changing from integer to floating point). A dedicated C function can ignore such events, if they are guaranteed not to happen.
The jBASE BASIC programmer may freely ignore the type of argument used when invoking the C function, as the jBASE BASIC compiler will automatically perform type conversion.

Example 1

DEFC INT cfunc( INT, FLOAT, VAR)

Var1 = cfunc( A, 45, B)

cfunc( 34, C, J)

You can call standard UNIX functions directly by declaring them with the DEFC statement according to their parameter requirements. You can only call them directly providing they return one of the type int or float/double or that the return type may be ignored.

Example 2

DEFC INT getpid()
CRT "Process id =":getpid()
Continue Reading...

Tuesday, January 4, 2011

jBase Infobasic Function CAT

The CATS function concatenates the corresponding elements in two dynamic arrays.

Command Syntax

CATS (DynArr1, DynArr2)

Syntax Elements

DynArr1 and DynArr2 represent dynamic arrays.

Notes

If one dynamic array supplied to the CATS function is null then the result of the CATS function is the non-null dynamic array.

Example

X = "a" : @VM : "b" : @VM : "c"
B = 1 : @VM : 2 : @VM : 3
Z = CATS(X, Y)
The assigned value to variable Z is:
a1 : @VM : b2 : @VM : c3

// NEW Example

A = "a" : @SVM : "b" : @VM : "c": @VM : "d"
B = "x" : @VM : "y" : @SVM : "z"
C = CATS(A, B)
The assigned value to variable C is:
ax : @SVM : b : @VM : cy : @SVM : z : @VM : d
Continue Reading...

Sunday, January 2, 2011

jBase Infobasic Function CALLONEXIT

The CALLONEXIT function call allows you to specify the name of a SUBROUTINE to call when the program terminates.

Command Syntax

rc = CALLONEXIT("ErrorExit")
The subroutine definition would look like this.
SUBROUTINE CALLONEXIT(parm1)
You can add parameters to the error subroutine by adding multi-values to the parameter to CALLONEXIT, which are passed to the called subroutine in the first parameter.

If you execute CALLONEXIT multiple times with the same subroutine name, it discards other calls.
If you execute CALLONEXIT multiple times with a different subroutine name, then upon exit multiple subroutines will be called in the order that CALLONEXIT was called.

Example

For example, consider the simple programs below. The program enters the debugger. If at this point the login session terminates for any reason (the line drops, the program is killed, the user enters 'off' at the debugger prompt) , the two specified subroutines (ErrorExit and EndProgram) will still be called just as they would if the program were allowed to terminate normally.
PROGRAM PROG1
rc = CALLONEXIT("ErrorExit")
EXECUTE "PROG2"
PROGRAM PROG2
rc = CALLONEXIT("EndProgram")
DEBUG
All efforts are made to call the subroutine under all circumstances. However, if a SIGKILL (signal 9) terminates the program, which cannot be trapped, it does not call the subroutine. This is a feature of operating systems, not a limitation. In addition, if the program terminates due to say a memory error, then calling the subroutines depends upon how badly the memory error has corrupted the memory.
Continue Reading...

Friday, December 31, 2010

jBase Infobasic Function DECRYPT

The DECRYPT function encrypts strings. see also ENCRYPT

Command Syntax

DECRYPT(string, key, method)

Syntax Elements

string => specifies the string to be encrypted.
key => is the value used to encrypt the string. Its use depends on method.
method => is a value, which indicates the encryption mechanism to use (See below):

The ENCRYPT and DECRYPT functions that are part of jBASE BASIC now support the following cipher methods (Defined in JBC.h)

JBASE_CRYPT_GENERAL General-purpose encryption scheme
JBASE_CRYPT_ROT13 Simple ROT13 algorithm. (Key not used)
JBASE_CRYPT_XOR11 XOR MOD11 algorithm. Uses the first character of a key as a seed value.
JBASE_CRYPT_RC2 RC2 algorithm
JBASE_CRYPT_DES DES algorithm
JBASE_CRYPT_3DES Three Key, Triple DES algorithm
JBASE_CRYPT_BLOWFISH Blowfish algorithm
JBASE_CRYPT_BASE64 (See below)

BASE64 is not really an encryption method, but more of an encoding. The reason for this is that the output of an encryption often results in a binary string. It allows binary data to be represented as a character string. BASE64 operation is not required but is performed in addition to the primary algorithm. e.g. JBASE_CRYPT_RC2_BASE64 ENCRYPT with this method is the same as a DECRYPT with method JBASE_CRYPT_RC2 followed
by DECRYPT with method JBASE_CRYPT_BASE64. DECRYPT with this method is the same as a DECRYPT with method JBASE_CRYPT_BASE64 followed by DECRYPT with method JBASE_CRYPT_RC2.

JBASE_CRYPT_RC2_BASE64 RC2 algorithm
JBASE_CRYPT_DES_BASE64 DES algorithm
JBASE_CRYPT_3DES_BASE64 Triple DES algorithm
JBASE_CRYPT_BLOWFISH _BASE64 Blowfish algorithm

Example

INCLUDE JBC.h
X = DECRYPT(X, Ekey, JBASE_CRYPT_GENERAL)
IF DECRYPT("rknzcyr”,"", JBASE_CRYPT_ROT13) = "example" THEN
CRT "ROT13 ok"
END
IF ENCRYPT("g{ehvkm","9", JBASE_CRYPT_XOR11) = "example" THEN
CRT "XOR.MOD11 ok"
END
cipher = JBASE_CRYPT_BLOWFISH_BASE64
key = "Our Very Secret Key"
str = "String to encrypt"
enc = ENCRYPT( str, key, cipher )
CRT "Encrypted: ":enc
dec = DECRYPT( enc, key, cipher )
CRT "Decrypted: ":dec

Output

Encrypted: xuy6DXxUkD32spyfsKEvUtXrsjP7mC+R
Decrypted: String to encrypt
Continue Reading...

jBase Infobasic Function ENCRYPT

The ENCRYPT function encrypts strings. see also DECRYPT

Command Syntax

ENCRYPT(string, key, method)

Syntax Elements

string => specifies the string for encryption.
key => is the value used to encrypt the string. Its use depends on method.
method => is a value, which indicates the encryption mechanism to use (See below):

The ENCRYPT and DECRYPT functions that are part of jBASE BASIC now support the following cipher methods (Defined in JBC.h)

JBASE_CRYPT_GENERAL General-purpose encryption scheme
JBASE_CRYPT_ROT13 Simple ROT13 algorithm. (Key not used)
JBASE_CRYPT_XOR11 XOR MOD11 algorithm. Uses the first character of a key as a seed value.
JBASE_CRYPT_RC2 RC2 algorithm
JBASE_CRYPT_DES DES algorithm
JBASE_CRYPT_3DES Three Key, Triple DES algorithm
JBASE_CRYPT_BLOWFISH Blowfish algorithm
JBASE_CRYPT_BASE64 (See below)
BASE64 is more of an encoding method rather than an encryption method. The reason for this is that the output of an encryption often results in a binary string, which allows the representation of binary data as a character string. Although not required the BASE64 operation is performed in addition to the primary algorithm. E.g. JBASE_CRYPT_RC2_BASE64

ENCRYPT with this method is the same as an ENCRYPT with method JBASE_CRYPT_RC2 followed by ENCRYPT with method JBASE_CRYPT_BASE64.

DECRYPT with this method is the same as a DECRYPT with method JBASE_CRYPT_BASE64 followed by DECRYPT with method JBASE_CRYPT_RC2.
JBASE_CRYPT_RC2_BASE64 RC2 algorithm
JBASE_CRYPT_DES_BASE64 DES algorithm
JBASE_CRYPT_3DES_BASE64 Triple DES algorithm
JBASE_CRYPT_BLOWFISH _BASE64 Blowfish algorithm

Example

INCLUDE JBC.h
X = DECRYPT(X, Ekey, JBASE_CRYPT_GENERAL)
IF DECRYPT("rknzcyr”,"", JBASE_CRYPT_ROT13) = "example" THEN
CRT "ROT13 ok"
END
IF ENCRYPT("g{ehvkm","9", JBASE_CRYPT_XOR11) = "example" THEN
CRT "XOR.MOD11 ok"
END
cipher = JBASE_CRYPT_BLOWFISH_BASE64
key = "Our Very Secret Key"
str = "String to encrypt"
enc = ENCRYPT( str, key, cipher )
CRT "Encrypted: ":enc
dec = DECRYPT( enc, key, cipher )
CRT "Decrypted: ":dec

Output

Encrypted: xuy6DXxUkD32spyfsKEvUtXrsjP7mC+R
Decrypted: String to encrypt
Continue Reading...

Tuesday, December 28, 2010

jBase Infobaisc Function CALLC

The CALLC command transfers program control to an external function (c.sub.name). The second form of the syntax calls a function whose name is stored in a jBASE BASIC variable (@var). The program could pass back return values in variables. CALLC arguments can be simple variables or complex expressions, but not arrays. Use CALLC as a command or function.

Command Syntax

CALLC c.sub.name [(argument1[,argument2]...)]
CALLC @var [(argument1[,argument2]...)]

Calling a C Program in jBASE

You must link the C program to jBASE before calling it from a BASIC program. Perform the following procedure to prepare jBASE for CALLC:
  • Write and compile the C program.
  • Define the C program call interface
  • Build the runtime version of jBASE (containing the linked C program).
  • Write, compile, and execute the Basic program

Calling a Function in Windows NT

The CALLC implementation in jBASE for Windows NT or Windows 2000 uses the Microsoft Windows Dynamic Link Library (DLL) facility. This facility allows separate pieces of code to call one another without permanently binding together. Linking between the separate pieces occurs at runtime (rather than compile time) through a DLL interface. For CALLC, developers create a DLL and then call that DLL from jBASE

Example

In the following example, the called subroutine draws a circle with its center at the twelfth row and twelfth column and a radius of 3:
RADIUS = 3
CENTER = "12,12"
CALLC DRAW.CIRCLE(RADIUS,CENTER)
In the next example, the subroutine name is stored in the variable SUB.NAME, and is indirectly called:
SUB.NAME = DRAW.CIRCLE
CALLC @SUB.NAME(RADIUS,CENTER)
The next example uses, CALLC as a function, assigning the return value of the subroutine PROGRAM.STATUS in the variable RESULT:
RESULT = CALLC PROGRAM.STATUS
Continue Reading...

Saturday, December 25, 2010

jBase Infobaisc Function XMLTOXML

Transform the XML using the XSL.

Command Syntax

XMLTOXML(xml,xsl,result)

Syntax Elements

If result=0, returned xml will contain a transformed version of XML using XSL
If result=1, returned xml will hold an error message

Example

Our Sample XSL



and our Sample XML


Bob


Amy


now we will use function XMLTOXML function and observe the output
newxml = XMLTOXML(xml,xsl,rc)
CRT newxml
on our display this output should b seen as

Bob

Amy

Continue Reading...

Thursday, December 23, 2010

jBase Infobaisc Function XMLTODYN

Converts the XML to a dynamic array using the optional XSL to transform. see also DYNTOXML

Command Syntax

XMLTODYN(XML,XSL,result)

Syntax Elements

Array = XMLTODYN(XML,XSL,result)
If result = 0 Array will contain a dynamic array built from the xml / xsl
If result <> 0, Array will contain an error message.

There is no requirement for xsl if you are reconverting from generic xml to dynarray.

Example

a = "Tom" : @AM : "Dick" : @AM : "Harry"
xml = DYNTOXML(a,"",result)
b = XMLTODYN(xml,"",result
CRT CHANGE(b ,@AM," ")

Output

Tom Dick Harry
If passing a stylesheet in the second parameter, it performs a transform to give a different format of the array.

XML Contents



Tom
Dick
Harry

Example 2

a = XMLTODYN(xml,xsl,rc)
CRT CHANGE(a,@AM," ")

XSL Contents








1



1



Continue Reading...

Wednesday, December 22, 2010

jBase Infobaisc Function DYNTOXML

Convert the array to XML using the optimal xsl to transform. see also XMLTODYN

Command Syntax

DYNTOXML (array,xsl,result)

Syntax Elements

XML = (DYNTOXML(array,””,result)
Takes the contents of the dynamic array held in an array, and returns a generic XML representation of that array or an error.

Example

a = "Tom" : @AM : "Dick" : @AM : "Harry"
xml = DYNTOXML(a,"",result)
CRT xml

Output



Tom
Dick
Harry

If a style sheet is passed in the second parameter, it performs a transform to give a different format of XML.

Example

xml = DYNTOXML(a,xsl,result)
CRT xml

Output



Tom
Dick
Harry

XSL Code















Continue Reading...

Friday, November 5, 2010

Temenos T24 Infobasic Command MATREAD

MATREAD is a command that is used to read the contents of a dimensioned/dynamic array. You can specify the id of the record to be picked up from the array. In case the read is successful, then the statements following the 'THEN' statements are executed else the statements following the 'ELSE' statement are executed.

Syntax

MATREAD array FROM FILE.VAR, RECORD.ID 
THEN CRT "THEN SCENARIO" 
ELSE CRT "ELSE SCENARIO"

Usage

MATRED Array1 from F.REGISTER.DETAILS,ID1 THEN ….. ELSE …..
The above statement will search for a record with id specified in the variable ID1, if found, it will transfer the record to the array Array1.
Continue Reading...

Temenos T24 Infobasic Command F.DELETE

F.DELETE is also a core T24 subroutine that is used to delete a record from a file.

Syntax

F.DELETE(FILE.NAME,Id.OF.RECORD.TO.BE.DELETED)

Usage

CALL F.DELETE(FN.CUS,Y.CUSID)
Continue Reading...

Tuesday, November 2, 2010

Temenos T24 Infobasic Command LOCATE

LOCATE statement is used to locate the position of a string or determine the position to insert in to maintain a specific sequence.

Syntax

LOCATE expr IN dynamic.array,STARTPOS
BY sort.expr SETTING variable
THEN statements ELSE statements

Additional Information

Sort.Expr :

AL -> Ascending left(Alpha sort)
AR -> Ascending right(Numeric sort)
DL -> Descending left(High-low alpha sort)
DR -> Descending right(High-low numeric sort)

Example

DAYS = "MON:"FM:"TUE":FM:"WED":FM:"THU":FM:"FRI"
LOCATE "WED" IN DAYS SETTING FOUND ELSE FOUND = 0
CRT "Position of WED in DAYS dynamic array :":FOUND
LOCATE "SAT" IN DAYS BY "AL" SETTING POS ELSE 
 INS "SAT" BEFORE DAYS
END
CRT "Position where SAT has been inserted :":POS
CRT "Days dynamic array after inserting SAT :":DAYS

Output

Position of WED in DAYS dynamic array : 3
Position where SAT has been inserted : 2
Days dynamic array after inserting SAT : MON||SAT||TUE||WED||THU||FRI
Continue Reading...
 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems