A2TOSING() Copies a given element from an array of arrays

  <aSingle> => a single dimensioned array


  Copies a given element position from a 2 dimensioned
  array of arrays into a single dimensioned array. <a2dim> is the
  source 2 dimensioned array. <nElement> is the element position
  within each sub-array to copy.

  Both DBSTRUCT() and DIRECTORY() are good examples.
  Each return an array of arrays. DBSTRUCT() for instance, returns
  the structure of the current database file in an array whose
  length is equal to the number of fields in the database file.
  Each element of the array is a subarray containing information
  for one field.  The subarrays have the following format:

        { fieldname, fieldtype, fieldlength,fielddecimals}

  To extract a single dimensioned array of, say, the
  field names, you could use A2TOSING() with
  A2TOSING(DBSTRUCT(),1). For the field types you would use
  A2TOSING(DBSTRUCT(),2), etc.

  Here is an example with DIRECTORY()

   aDir         := DIRECTORY()
   aNames       := A2TOSING(adir,1)
   nWhichFile   := mchoice(aNames,10,10,20,20,"Which File?")


2 responses to “SP_A2TOSING

  1. Pingback: SP Array Functions | Viva Clipper !

  2. Pingback: SP Functions | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.