HELPLIB.HLB  —  PASCAL  Predeclared Routines, Null String
  VSI Pascal provides routines  for  manipulating  null-terminated
  strings.   These  routines use the predeclared type C_STR_T as a
  pointer to a null-terminated  character  string.   The  compiler
  assumes  that  buffers are large enough to hold their values and
  null-terminated  strings  are  actually  terminated  by  a  null
  character.

1  –  C_STR

  The C_STR function takes a compile-time  string  expression  and
  returns  a  C_STR_T  pointer  to  a static string literal with a
  terminating null character.

  Syntax:

     C_STR(e)

  The C_STR function can also accept a Pascal variable  of  either
  PACKED ARRAY OF CHAR, VARYING OF CHAR, or STRING.

  Syntax:

     C_STR(v)

  In this form, it will return a C_STR_T value that represents the
  first  character  in  the string variable.  It does not ensure a
  terminating  null  byte.   The  programmer   must   handle   the
  null-termination   to  treat  a  Pascal  string  variable  as  a
  null-terminated string.

2  –  MALLOC_C_STR

  The MALLOC_C_STR function  takes  a  Pascal  string  expression,
  calls the C routine malloc() to allocate memory, initializes the
  memory with the  string  expression,  and  then  terminates  the
  string with a null-charcter.

  Syntax:

     MALLOC_C_STR(e)

  The type of the expression e must be a Pascal string expression.
  The  function  result is a C_STR_T pointer to the null-terminted
  string.  The amount of memory allocated with malloc()  is  equal
  to  the  length  of  the string expression plus one.  The memory
  allocated with MALLOC_C_STR  must  be  deallocated  with  the  C
  free()  routine.  The compiler will not allow C_STR_T parameters
  with the NEW and DISPOSE routines.

3  –  PAS_STR

  The PAS_STR function  returns  a  Pascal  string  value  from  a
  C_STR_T value.

  Syntax:

     PAS_STR(e)

  The type of the expression e must be C_STR_T.  It is an error if
  the expression is NIL.

4  –  PAS_STRCPY

  The PAS_STRCPY function copies a Pascal string  expression  into
  memory pointed to by C_STR_T.

  Syntax:

     PAS_STRCPY(v, e)

  The type of the variable v must be C_STR_T.   The  type  of  the
  expression  e  must  be  a Pascal string expression.  The Pascal
  string is copied into the memory pointed to by the  variable  v.
  The  memory  is  then  terminated  with  a  null character.  The
  function returns a C_STR_T value  representing  the  destination
  (such as, the same value as contained by the variable v).

  The behavior of PAS_STRCPY is undefined if  the  length  of  the
  Pascal  string expression is greater than or equal to the amount
  of memory pointed to by the variable v.  It is an error  if  the
  variable v is NIL.
Close Help