Wednesday, May 11, 2011

Harbour/xharbour Diff :10/57 - HB_ARRAYTOPARAMS() FUNCTION by Przemyslaw Czerpak

###    HB_ARRAYTOPARAMS() FUNCTION    ###
=========================================
Harbour has special function which allows to convert array into
list of items which can be used as function parameters, array
values or array indexes in the same way as '...' operator:
   hb_arrayToParams(  ) -> [ 1 ] [, [ N ] ]
i.e.:
      proc main( ... )
         local aParams := hb_aParams(), n
         /* remove parameters starting with "--" */
         n := 1
         while n < len( aParams )
            if left( aParams[ n ], 2 ) == "--"
               hb_adel( aParams, n, .t. )
            else
               ++n
            endif
         enddo
         ? "Public parameters:", hb_arrayToParams( aParams )
      return

Note for Clipper users: 'hb_adel( aParams, n, .t. )' in above example
works like 'adel( aParams, n ); asize( aParams, len( aParams ) - 1 )'.

This functionality is unique to Harbour and xHarbour does not support
hb_arrayToParams() or similar function.

No comments:

Post a Comment