PowerBuilder – PFC String service extension

Posted on Monday, February 21st, 2011 at 8:20 pm in

Here is a simple modification to the PFC string service (n_cst_string) which will parse out an array of any datatype and returned a delimited string of the contents. The new method is a polymorph of the existing of_arraytostring.

public function long of_arraytostring (any aa_array[], string as_delimiter, ref string as_string)

// convert array to string array and then send to standard PFC function
long ll_ac, ll_i
string ls_array[], ls_format

ll_ac = Upperbound(aa_array)
FOR ll_i = 1 to ll_ac
	IF ls_format = '' THEN
		CHOOSE CASE Classname(aa_array[ll_i])
			CASE "string","char"
			CASE "datetime"
				ls_format = 'mm-dd-yyyy hh:mm:ss'
			CASE "date"
				ls_format = 'mm-dd-yyyy'
			CASE "time"
				ls_format = 'hh:mm:ss'
			CASE ELSE
				
		END CHOOSE
	END IF
	ls_array[ll_i] = string(aa_array[ll_i], ls_format)
NEXT

RETURN of_arraytostring(ls_array,as_delimiter,as_string)
You might also be interested in

Top