User Tools

Site Tools


standard_c_functions_in_clarion_s_runtime_library.htm
Navigation:  Advanced Topics > API Calls and Advanced Resources >====== Standard C Functions in Clarion's Runtime Library ====== Previous pageReturn to chapter overviewNext page

Conversion Functions

Integer Math

Char Type Functions

Utility Functions

String Functions

Low-Level File Manipulation

The following functions comprise a sub-set of the standard Clarion library that you can call from your Clarion, C/C++, or Modula-2 code. All of these functions are fully documented in the Topspeed C Library Reference manual (or in any ANSI-standard C library reference) and so, are not documented here. Unless otherwise indicated, assume that the functions operate exactly as documented.

The purpose of this list is simply to let you know what C standard library functions are available and the correct prototypes for each language.

Conversion Functions

Please note that some of the following functions require pointers to null terminated strings as parameters. Modula-2 programmers should use the Modula library procedure Str.StrToC to convert strings to null terminated equivalents. Also, the pragma call(o_a_size⇒off, o_a_copy⇒off) must be issued to prevent the passing of array size information to the run-time procedures.

Atof Convert string to floating point.
C++: double atof(const char *_nptr)
Modula-2: atof( VAR _nptr: ARRAY OF CHAR): LONGREAL;
Clarion: AToF(*cstring),real,raw,name('_atof')
Atoi Convert string to integer.
C++: int atoi(const char *_nptr)
Modula-2: atoi(VAR _nptr: ARRAY OF CHAR): INTEGER;
Clarion: AToI(*cstring),short,raw,name('_atoi')
Atoll Convert string to long.
C++: long atol(const char *_nptr)
Modula-2: atol( VAR _nptr: ARRAY OF CHAR): LONGINT;
Clarion: AToL(*cstring),long,raw,name('_atol')
Atoul Convert string to unsigned long.
C++: unsigned long atoul(const char *_nptr)
Modula-2: atoul(VAR _nptr: ARRAY OF CHAR): LONGCARD;
Clarion: AToUL(*cstring),ulong,raw,name('_atoul')

Integer Math

Abs Integer absolute value.
C++: int abs(int _num)
Modula-2: abs(_num: INTEGER): INTEGER;
Clarion: API_Abs(short),short,name('_abs')!Renamed to avoid conflict with Builtins.Clw
Labs Long integer absolute value.
C++: long labs(long _j)
Modula-2: labs(_i: LONGINT): LONGINT;
Clarion: LAbs(long),long,name('_labs')

Char Type Functions

The following functions have only been tested when implemented as functions. We do not advise defining _CT_MTF to implement the functions as macros.

Toupper Test and convert if lowercase.
C++: int toupper(int c)
Modula-2: toupper(c: INTEGER):INTEGER;
Clarion: ToUpper(short),short,name('_toupper')
Tolower Test and convert if uppercase.
C++: int tolower(int c)
Modula-2: tolower(c: INTEGER): INTEGER;
Clarion: ToLower(short),short,name('_tolower')
Isascii ASCII test function.
C++: int isascii(int c)
Modula-2: isascii(c: INTEGER): INTEGER;
Clarion: IsAscii(short),short,name('_isascii')
Iscntrl Control character test function.
C++: int iscntrl(int c)
Modula-2: iscntrl(c: INTEGER): INTEGER;
Clarion: IsCntrl(short),short,name('_iscntrl')
Isdigit Numerics test function.
C++: int isdigit(int c)
Modula-2: isdigit(c: INTEGER): INTEGER;
Clarion: IsDigit(short),short,name('_isdigit')
Isprint Printable including space test function.
C++: int isprint(int c)
Modula-2: isprint(c: INTEGER): INTEGER;
Clarion: IsPrint(short),short,name('_isprint')
Ispunct Punctuation character test function.
C++: int ispunc(int c)
Modula-2: ispunc(c: INTEGER): INTEGER;
Clarion: IsPunct(short),short,name('_ispunct')
Isspace Whitespace test function.
C++: int isspace(int c)
Modula-2: isspace(c: INTEGER): INTEGER;
Clarion: IsSpace(short),short,name('_isspace')
Isxdigit Hex digit test function.
C++: int isxdigit(int c)
Modula-2: isxdigit(c: INTEGER): INTEGER;
Clarion: IsXDigit(short),short,name('_isxdigit')

Utility Functions

Rand Return pseudorandom integer.
C++: int rand(void)
Modula-2: rand(): INTEGER;
Clarion: Rand(),short,name('_rand')
   
Randomize Set pseudorandom seed with system time.
C++: void randomize(void)
Modula-2: randomize()
Clarion: Randomize(),name('_randomize')
Srand Set pseudorandom seed with specified number.
C++: void srand(unsigned _seed)
Modula-2: srand(_seed: CARDINAL);
Clarion: SRand(ushort),name('_srand')

String Functions

Strcat Concatenate two strings.
C++: char *strcat(char *_dest, const char *_source)
Modula-2: Not available
Clarion: StrCat(*cstring,*cstring),cstring,raw,name('_strcat')
Strcmp Compare two strings.
C++: int strcmp(const char *_s1, const char *_s2)
Modula-2: Not available
Clarion: StrCmp(*cstring,*cstring),short,raw,name('_strcmp')
Chrcmp Compare two characters
C++: int chrcmp(char _c1, char _c2)
Modula-2: chrcmp(_c1,_c2: CHAR): INTEGER;
Clarion: ChrCmp(byte,byte),short,name('_chrcmp')
Strequ
C++: int strequ(const char *_s1, const char *_s2)
Modula-2: Not available
Clarion: StrEqu(*cstring,*cstring),short,raw,name('_strequ')
Strcpy Copy one string to another, return destination address.
C++: char *strcpy(char *_dest, const char *_source)
Modula-2: Not available
Clarion: StrCpy(*cstring, *cstring), cstring, raw, name('_strcpy')
Strlen Return string length.
C++: unsigned strlen(const char *_s)
Modula-2: strlen(VAR _s: ARRAY OF CHAR): CARDINAL;
Clarion: StrLen(*cstring),ushort,raw,name('_strlen')
Strchr Find character in string.
C++: char *strchr(const char *_s, int _c)
Modula-2: Not available
Clarion: StrChr(*cstring,short),cstring,raw,name('_strchr')
Strcspn Finds one of a set of characters in string.
C++: unsigned strcspn(const char *_s1, const char *_s2)
Modula-2: Not available
Clarion: StrCSpn(*cstring, *cstring), ushort, raw, name('_strcspn')
Strspn Find first character with no match in given character set.
C++: unsigned strspn(const char *_s1, const char *_s2)
Modula-2: Not available
Clarion: StrSpn(*cstring,*cstring),ushort,raw,name('_strspn')
Strstr Find first occurrence of substring in a string.
C++: char *strstr(const char *_s1, const char *_s2)
Modula-2: Not available
Clarion: StrStr(*cstring,*cstring),cstring,raw,name('_strstr')
Strtok Find next token in string.
C++: char *strtok(char *_s1, const char *_s2)
Modula-2: Not available
Clarion: StrTok(*cstring,*cstring),cstring,raw,name('_strtok')
Strpbrk Find first occurrence of character.
C++: char *strpbrk(const char *_s1, const char *_s2)
Modula-2: Not available
Clarion: StrPBrk(*cstring, *cstring), cstring, raw, name('_strpbrk')
Strrchr Find last occurrence of character.
C++: char *strrchr(const char *_s, int _c)
Modula-2: Not available
Clarion: StrRChr(*cstring,short),cstring,raw,name('_strrchr')
Strlwr Convert to lower case.
C++: char *strlwr(char *_s)
Modula-2: Not available
Clarion: StrLwr(*cstring),cstring,raw,name('_strlwr')
Strupr Convert to upper case.
C++: char *strupr(char *_s)
Modula-2: Not available
Clarion: StrUpr(*cstring),cstring,raw,name('_strupr')
Strdup Duplicate string.
C++: char *strdup(const char *_s)
Modula-2: Not available
Clarion: StrDup(*cstring),cstring,raw,name('_strdup')
Strrev Reverse string.
C++: char *strrev(char *_s)
Modula-2: Not available
Clarion: StrRev(*cstring),cstring,raw,name('_strrev')
Strncat Concatenate n characters.
C++: char *strncat(char *_dest, const char *_source, unsigned _n)
Modula-2: Not available
Clarion: StrNCat(*cstring, *cstring, ushort), cstring, raw, name('_strncat')
Strncmp Compare n characters.
C++: int strncmp(const char *_s1, const char *_s2, unsigned _n)
Modula-2: Not available
Clarion: StrNCmp(*cstring, *cstring, ushort), short, raw, name('_strncmp')
Strncpy Copy n characters.
C++: char * strncpy(char *_dest, const char *_source, unsigned _n)
Modula-2: Not available
Clarion: StrNCpy(*cstring, *cstring, ushort), cstring, raw, name('_strncpy')
Strnicmp Compare n characters regardless of case.
C++: int stricmp(const char *_s1, const char *_s2, unsigned _n)
Modula-2: Not available
Clarion: StrNICmp(*cstring, *cstring, ushort), short, raw, name('_strnicmp')

Low-Level File Manipulation

Access Checks whether the file (or directory) specified by the path parameter exists, and (if not a directory) whether it can be accessed in the specified mode. The function returns 0 if access is permitted using the specified mode, -1 if it fails the check. Mode of 0 checks for existence, mode of 2 checks for write permission, mode of 4 checks for read permission, and 6 checks for read/write.
C++: int_access(const char *path,int access)
Modula-2: _access(VAR path: ARRAY OF CHAR; access:INTEGER): INTEGER;
Clarion: Access(*cstring,short),short,raw,name('_access')
Chmod Set file's access mode.
C++: int _chmod(const char *path, int mode)
Modula-2: _chmod(VAR path: ARRAY OF CHAR; mode: INTEGER): INTEGER;
Clarion: ChMod(*cstring,short),short,raw,name('_chmod')
remove Deletes the file specified by the path parameter.
C++: int _remove(const char *_path)
Modula-2: _remove(VAR _path: ARRAY OF CHAR): INTEGER;
Clarion: API_Remove(*cstring),short,raw,name('_remove')!Renamed to avoid conflict with Builtins.Clw
rename Changes the name of the file or directory specified by the oldname parameter.
C++: int _rename(const char *_oldname, const char *_newname)
Modula-2: _rename(VAR _oldname, VAR _newname: ARRAY OF CHAR): INTEGER;
Clarion: API_Rename(*cstring, *cstring), short, raw, name('_rename')!Renamed to avoid conflict with Builtins.Clw
fnmerge Builds a complete path name from its component parts – drive, directory, filename, and extension.
C++: void _fnmerge(char *_path, const char *_drive, const char *_dir, const char *_name, const char *_ext)
Modula-2: _fnmerge(VAR _path, VAR _drive, VAR _dir, VAR _name, VAR _ext: ARRAY OF CHAR);
Clarion: FnMerge(*cstring, *cstring, *cstring, *cstring, *cstring), raw, name('_fnmerge')Note: fnmerge is actually called using PathMerge in the prototypes in CWUTIL.INC
fnsplit This function breaks a complete path name into its component parts – drive, directory, filename, and extension.
C++: int _fnsplit(const char *_path, char *_drive, char *_dir, char *_name, char *_ext)
Modula-2: _fnsplit(VAR_path,VAR _drive,VAR _dir,VAR _name,VAR _ext:ARRAY OF CHAR):INTEGER;
Clarion: FnSplit(*cstring, *cstring, *cstring, *cstring, *cstring), short, raw, name('_fnsplit')Note: fnsplit is actually called using PathSplit using the prototypes in CWUTIL.INC.
mkdir Creates a new directory with the name passed in the path parameter.
C++: int _mkdir(const char *_path)
Modula-2: _mkdir(VAR _path: ARRAY OF CHAR): INTEGER;
Clarion: MkDir(*cstring),short,raw,name('_mkdir') Equivalent to CreateDirectory
rmdir removes the directory specified in the path parameter.
C++: int _rmdir(const char *_path)
Modula-2: _rmdir(VAR _path: ARRAY OF CHAR):INTEGER;
Clarion: RmDir(*cstring),short,raw,name('_rmdir')Equivalent to RemoveDirectory
chdir Change directory.
C++: int _chdir(const char *_path)
Modula-2: _chdir(VAR _path: ARRAY OF CHAR): INTEGER;
Clarion: ChDir(*cstring),short,raw,name('_chdir')
standard_c_functions_in_clarion_s_runtime_library.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1