previous next top contents index framed top this page unframed
Figure 32–89. $cvFieldToString
| STRING <macro> $cvFieldToString (<POINTER or ADDRESS> a; <field name> fld; OPTIONAL POINTER($area) area); |
$cvFieldToString is useful for converting a C string to a MAINSAIL STRING.
$cvFieldToString forms an inplace string using:
$cvFieldToStringInPlace(a,fld)
then, if the result is not the empty STRING, copies the STRING text into area (which defaults to $defaultArea) and returns a STRING descriptor for the copied text.
An example of the use of $copyStringToField, $cvFieldToStringInPlace, and $cvFieldToString:
$ALIGN CLASS c ($CHAR $INPLACEARRAY(0 TO 9) cAry);
ADDRESS(c) a;
STRING s;
s := "Hello World";
$copyStringToField(s,a,cAry);
# s is truncated to 9 chars + NUL
$cvFieldToStringInPlace(a,cAry) = "Hello Wor", which directly references the characters in the field cAry.
$cvFieldToString(a,cAry) is also "Hello Wor", but the referenced characters are in a STRING space for $defaultArea.
MAINSAIL Language Manual, Section 32.86