
The function is a form of computation that has been programmed in advance to be able to provide value if the parameter in this function is given the value.
The procedure is no different with a program, the multiple instructions connected together to achieve certain goals. In pemakaianya, the program consists of several procedures. Usually the location / use the function in the procedure is always different. In the professional lan foxbase there are about 200 functions that are ready for use, eg absolute function with the following syntax :
ABS(expN>)
Where : ABS is ABSOLUT function and expN ia parameter.
Example :
? ABS(-34)
34
? ABS(34-76)
42
In addition to the functions that ready-made, professional foxbase-LAN also allows programming lan create a function for a particular purpose. Such functions are called user-defined function (UDF).
examples of the formation function CENTRE.
FUNCTION Centre
* Syntax : Centre (<expC>,<expN>)
*
PRIVATE string, width
PARAMETER string, width
IF LEN(string) >= width
RETRUN(string)
ENDIF
RETRUN SPACE(int(width/2) - INT(LEN(string/2) + string
examples of the formation function PROF_MGN
FUNCTION prof_mgn
* syntax prof_mgn(<expN1>,<expN2>)
*
PARAMETER cost.price
margin = ROUND((price-cost)/price*100.1)
RETRUN margin
Example a PROSEDUR
* Program COBA.PRG
*
SET TALK OFF
CLEAR
PUBLIC k,l
x=5
y=6
z=7
DO TAMBAH
DO KALI
? k
? l
*
PROC TAMBAH
k = x+y+z
RETRUN
*
1 = x+y+z
RETRUN



0 komentar:
Posting Komentar