Variable parameters in C4gl
Posted in 1995
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Is it possible to create a C4gl function that will accept a variable number of arguments, in a similar fashion to the way that the VARARGS works in C. e.g. let l_str = str_cat("one", "two", "three") let l_str = str_cat("one", "two") I have the code for the function str_cat() below. The problem is that C4gl complains at compile time error -4333 the second call has a different argument count to the first. Whilst the function can be called with varying arguments this must be done in a separate module - not very useful. /* ------------------------------------------------------------------------------- MODULE : %M% VERSION : %I% LIBRARY : libgen FUNCTION : str_cat PARAMETERS : any number of parameters RETURNS : string DESCRIPTION : packs parameters into a single space delimited string AMENDMENTS : 09.01.95 - at - created ------------------------------------------------------------------------------- */ #define MAX_STRING 512 extern void clip(); int str_cat(nargs) int nargs; { char *getenv(); char str[3][MAX_STRING]; strlen("XXX"); str[2][0] = 0; while(nargs--) { popquote (str[0], MAX_STRING); clip (str[0], MAX_STRING); strcpy (str[1], str[2]); sprintf (str[2], "%s %s", str[0], str[1]); } retquote(str[2]); return(1); } It may be possible to do this using CPP macros but I'm not sure. Thanks Aaron Trewern