$TYPECHECK ON
CONST PI=ACOS(-1)
FUNCTION GetFileName(file AS STRING) AS STRING
result=RIGHT$(file,LEN(file)-RINSTR(file,"\"))
END FUNCTION
FUNCTION GetPathName(file AS STRING) AS STRING
result=LEFT$(file,RINSTR(file,"\")-1)
END FUNCTION
FUNCTION GetFileExt(file AS STRING) AS STRING
result=RIGHT$(file,LEN(file)-RINSTR(file,"."))
END FUNCTION
FUNCTION Word$(s AS STRING,index AS INTEGER) AS STRING
DIM stemp AS STRING
DIM i AS INTEGER
DIM flagSpace AS INTEGER
stemp=""
FOR i=1 TO LEN(s)
IF MID$(s,i,1)<>SPACE$(1) THEN
stemp=stemp+MID$(s,i,1)
flagSpace=0
ELSE
IF flagSpace=0 THEN stemp=stemp+SPACE$(1)
flagSpace=1
END IF
NEXT i
stemp=LTRIM$(RTRIM$(stemp))
result=FIELD$(stemp," ",index)
END FUNCTION
FUNCTION GetWordCount(s AS STRING) AS INTEGER
DIM flagStop AS INTEGER
DIM counter AS INTEGER
counter=1
flagStop=0
WHILE flagStop=0
IF Word$(s,counter)<>"" THEN
counter=counter+1
ELSE
flagStop=1
END IF
WEND
result=counter-1
END FUNCTION
FUNCTION RemoveChar$(s AS STRING,char AS STRING) AS STRING
DIM source AS STRING
IF s<>"" THEN
source=s
WHILE INSTR(source,char)<>0
source=LEFT$(source,INSTR(source,char)-1)+MID$(source,INSTR(source,char)+LEN(char))
WEND
result=source
END IF
END FUNCTION
FUNCTION Trim$(s AS STRING) AS STRING
Result=LTRIM$(RTRIM$(s))
END FUNCTION
FUNCTION Ratio(Value1 AS DOUBLE,Value2 AS DOUBLE) AS DOUBLE
Result=((Value1-Value2)*100)/Value1
END FUNCTION
FUNCTION GetRadian(degrees AS DOUBLE) AS DOUBLE
Result=degrees*(Pi/180)
END FUNCTION
FUNCTION GetDegrees(radian AS DOUBLE) AS DOUBLE
Result=radian*(180/Pi)
END FUNCTION
FUNCTION Distance(x AS DOUBLE,y AS DOUBLE) AS DOUBLE
Result=SQR(x^2+y^2)
END FUNCTION
FUNCTION Surface(Width AS DOUBLE,Height AS DOUBLE) AS DOUBLE
Result=Width*Height
END FUNCTION
FUNCTION GetBlue(COLOR AS LONG) AS LONG
Result=INT(COLOR/65536)
END FUNCTION
FUNCTION GetRed(COLOR AS LONG) AS LONG
DIM blue AS LONG
DIM green AS LONG
blue=INT(COLOR/65536)
green=INT((COLOR-(blue*65536))/256)
Result=INT(COLOR-(blue*65536)-(green*256))
END FUNCTION
FUNCTION GetGreen(COLOR AS LONG) AS LONG
DIM blue AS LONG
blue=INT(COLOR/65536)
Result=INT((COLOR-(blue*65536))/256)
END FUNCTION
|