uf_ds_from_array() gets an array and creates a DataStore, the only column of which (named "the_col") contains the array's values. It is useful in situations when you have an array, but it's faster or simply more convenient to process its values when they are in a DataStore (which has fast built-in functions to avoid looping on the array). A classic example - sorting a huge array. It's faster to convert it to a DS and call Sort().
First of all, add to your util NVO the function uf_get_pb_version(). After that, add uf_ds_from_array(). It has 2 overloads - for string and long data types:
/********************************************************************************************************************** Dscr: Gets STRING array and creates a DS, the only column of which (named "the_col") contains the array's values. After the values, previously converted to a DataStore by this function, have been processed, they can be easily converted back to an array by accessing the DataStore's property object.the_col.current:
lds_temp = uf_ds_from_array(ls_arr[]) ...massage data in DataStore... ls_arr[] = lds_temp.object.the_col.current
For LONG array, use another overload. *********************************************************************************************************************** Arg: as_arr[] *********************************************************************************************************************** Ret: DataStore *********************************************************************************************************************** Developer: Michael Zuskin - http://linkedin.com/in/zuskin | http://code.intfast.ca/ **********************************************************************************************************************/ string ls_source string ls_error string ls_pb_version DataStore lds
/********************************************************************************************************************** Dscr: Gets LONG array and creates a DS, the only column of which (named 'the_col') contains the array's values. After the values, previously converted to a DataStore by this function, have been processed, they can be easily converted back to an array by accessing the DataStore's property object.the_col.current:
lds_temp = uf_ds_from_array(ll_arr[]) ...massage data in DataStore... ll_arr[] = lds_temp.object.the_col.current
For STRING array, use another overload. *********************************************************************************************************************** Arg: al_arr[] *********************************************************************************************************************** Ret: DataStore *********************************************************************************************************************** Developer: Michael Zuskin - http://linkedin.com/in/zuskin | http://code.intfast.ca/ **********************************************************************************************************************/ string ls_source string ls_error string ls_pb_version DataStore lds
if UpperBound(al_arr) > 0 then lds.object.the_col.current = al_arr end if
return lds
When the values, previously converted to a DataStore by uf_ds_from_array(), have been processed , they can be easily converted back to an array by accessing the DataStore's property object.the_col.current: