I have defined a function called frequency() which tabluates the count of every unique value in a table. It works fine. I created a new function with no parameters using the function genie, called freq() and then copy and pasted the same code from frequency() into this code, except that I changed the function name to freq(). My intent was to add another parameter to allow the user to define the length of the returned string.
However, the original function works fine, but the clone even without changes returns an empty string. The code for each function is listed below. Both are saved. Does A5 store the function definition somewhere other than the code editor? What am I not seeing that makes one work and the other not?
FUNCTION frequency AS C (tablename AS C, fieldname AS C)
dim valuelist as C
dim countlist as C
fieldname = "''+" +fieldname
valuelist = table.external_record_content_get(tablename,fieldname,fieldname,"unique_key_value()")
valuelist = *for_each(val1, alltrim(val1),valuelist)
maxlen = max_str_length(valuelist, chr(13)+chr(10))
countlist = CRlf()+*for_each(valu,padr(valu,maxlen+2,".") + " " +tablecount(tablename,fieldname + "=" +quote(valu)) ,valuelist)
frequency = countlist
END FUNCTION
FUNCTION freq AS C(tablename AS C, fieldname AS C)
dim valuelist as C
dim countlist as C
fieldname = "''+" +fieldname
valuelist = table.external_record_content_get(tablename,fieldname,fieldname,"unique_key_value()")
valuelist = *for_each(val1, alltrim(val1),valuelist)
maxlen = max_str_length(valuelist, chr(13)+chr(10))
countlist = CRlf()+*for_each(valu,padr(valu,maxlen+2,".") + " " +tablecount(tablename,fieldname + "=" +quote(valu)) ,valuelist)
frequency = countlist
END FUNCTION
Thank,
Dave
However, the original function works fine, but the clone even without changes returns an empty string. The code for each function is listed below. Both are saved. Does A5 store the function definition somewhere other than the code editor? What am I not seeing that makes one work and the other not?
FUNCTION frequency AS C (tablename AS C, fieldname AS C)
dim valuelist as C
dim countlist as C
fieldname = "''+" +fieldname
valuelist = table.external_record_content_get(tablename,fieldname,fieldname,"unique_key_value()")
valuelist = *for_each(val1, alltrim(val1),valuelist)
maxlen = max_str_length(valuelist, chr(13)+chr(10))
countlist = CRlf()+*for_each(valu,padr(valu,maxlen+2,".") + " " +tablecount(tablename,fieldname + "=" +quote(valu)) ,valuelist)
frequency = countlist
END FUNCTION
FUNCTION freq AS C(tablename AS C, fieldname AS C)
dim valuelist as C
dim countlist as C
fieldname = "''+" +fieldname
valuelist = table.external_record_content_get(tablename,fieldname,fieldname,"unique_key_value()")
valuelist = *for_each(val1, alltrim(val1),valuelist)
maxlen = max_str_length(valuelist, chr(13)+chr(10))
countlist = CRlf()+*for_each(valu,padr(valu,maxlen+2,".") + " " +tablecount(tablename,fieldname + "=" +quote(valu)) ,valuelist)
frequency = countlist
END FUNCTION
Thank,
Dave
Comment