Powered by QM on a Linux server
Help and Support

KnowledgeBase 00057: The VSLICE() Function

Last updated: 27 Dec 2018
Applies to: All versions
Top level index       Full Index Search Tips
Previous article     Next article

Sometimes a program needs to extract data related to a specific value or subvalue position in a set of associated fields. The function described here makes this easy.

The VSLICE() Function

The VSLICE() function (value slice) returns a string formed by extracting a given value or subvalue position from a dynamic array.

   VSLICE(string, vpos) 
   VSLICE(string, vpos, svpos) 

The first form of this function returns the data in the requested value position from each field of the supplied string. Where a value contains subvalues, they are all included in the returned data.

The behaviour of the second form depends on svpos. If this is less than one, the returned data contains only the subvalue of each field/value but the value marks are retained to match the structure of the original data.

If svpos is one or greater, the subvalue is extracted from the specified value position and no value marks are included in the result.


The QMBasic DIR() function returns a dynamic array of items in a directory, with each item as a separate field. The fields are formed from three values containing the item name, the item type, and the file attributes. If an application needs only the item names, this can be achieved with a statement of the form


Related Articles


Please tell us if this article was helpful
Very     Slightly     Not at all
Email (optional)