SVI - Create a string from a template and values

Top  Previous  Next

Syntax

 

<cString> := SVI( <cStringTermplate {, <fill-Ins1..10> }  )

 

Parameters

 

<cStringTemplate>

 

A string that contains literal text and references to the fill-ins passed as additional parameters. The references are replaced with their respective fill-ins. A reference consists of an "&" and fill-in-number attached to it. For example &2 references fill-in 2.

 

<fill-Ins1..10>

 

Values to be used for replacing the references in <cStringTemplate>.  

 

Return value

 

A string made up by <cStringTemplate> after replacing all fill-in-references.

 

Description

 

SVI uses a string template and fill-in values to put together a new string. The string template contains references to the values. The references are replaced with their respective values. References to values start with an "&" followed by a fill-in number or a standard reference id. Assignment of passed values to references is done via their numbers. In addition to the fill-ins explicitly passed as parameters, there are these standard reference ids:

 

       &PL        = current procedure name and line

       &P        = current procedure

       &L        = current line

       &D        = current date

       &T        = current time

 

The fill-in values can be of any type. Var2Char() is used for stringification of all types except "date". Date values are stringified using the DToC() function. The fill-in values are AllTrimmed.

 

Classification

 

Core

       

Category

 

Array and String Utility

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL handle

 

* Try to open a file that does not exist

handle := FOpen("DefinitelyNotThere")

 

* Problems encountered?

IF handle == -1

 

  * Display the error and terminate the program

  SysError(SVI("Error in &PL at @&D-&T. Handle: &1, Message: &2",;

                handle,WindowsErrorText()))

 

ENDIF

 

RETURN NIL