home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / bbs / pibterm / pibt3sp1 / copystoa.pas < prev    next >
Pascal/Delphi Source File  |  1985-08-11  |  4KB  |  87 lines

  1. (*--------------------------------------------------------------------------*)
  2. (*                 CopyStoA -- Copy string to character array               *)
  3. (*--------------------------------------------------------------------------*)
  4.  
  5. PROCEDURE CopyStoA( S : AnyStr; VAR A ; Length_A : INTEGER );
  6.  
  7. (*--------------------------------------------------------------------------*)
  8. (*                                                                          *)
  9. (*    Procedure: CopyStoA                                                   *)
  10. (*                                                                          *)
  11. (*    Purpose:   Copies string to character array, blank fill               *)
  12. (*                                                                          *)
  13. (*    Calling Sequence:                                                     *)
  14. (*                                                                          *)
  15. (*       CopyStoA( S : AnyStr; VAR A ; Length_A: INTEGER );                 *)
  16. (*                                                                          *)
  17. (*          S        --- String to be copied                                *)
  18. (*          A        --- Character array to be copied into                  *)
  19. (*          Length_A --- No. of characters in A                             *)
  20. (*                                                                          *)
  21. (*    Calls:  None                                                          *)
  22. (*                                                                          *)
  23. (*--------------------------------------------------------------------------*)
  24.  
  25. VAR
  26.    I    : INTEGER;
  27.    AA   : PACKED ARRAY[ 1 .. 1 ] OF CHAR ABSOLUTE A;
  28.  
  29. BEGIN (* CopyStoA *)
  30.  
  31.    FOR I := 1 TO MIN( Length_A , LENGTH( S ) ) DO
  32.       AA[I] := S[I];
  33.  
  34.    FOR I := ( I + 1 ) TO Length_A DO
  35.       AA[I] := ' ';
  36.  
  37. END   (* CopyStoA *);
  38.  
  39. (*--------------------------------------------------------------------------*)
  40. (*       CopyS2AR -- Copy string to character array, right adjust           *)
  41. (*--------------------------------------------------------------------------*)
  42.  
  43. PROCEDURE CopyS2AR( S : AnyStr; VAR A ; Length_A : INTEGER );
  44.  
  45. (*--------------------------------------------------------------------------*)
  46. (*                                                                          *)
  47. (*    Procedure: CopyS2AR                                                   *)
  48. (*                                                                          *)
  49. (*    Purpose:   Copies string to character array, blank fill on left       *)
  50. (*                                                                          *)
  51. (*    Calling Sequence:                                                     *)
  52. (*                                                                          *)
  53. (*       CopyS2AR( S : AnyStr; VAR A ; Length_A: INTEGER );                 *)
  54. (*                                                                          *)
  55. (*          S        --- String to be copied                                *)
  56. (*          A        --- Character array to be copied into                  *)
  57. (*          Length_A --- No. of characters in A                             *)
  58. (*                                                                          *)
  59. (*    Calls:  None                                                          *)
  60. (*                                                                          *)
  61. (*--------------------------------------------------------------------------*)
  62.  
  63. VAR
  64.    I        : INTEGER;
  65.    Len_S    : INTEGER;
  66.    Len_A    : INTEGER;
  67.    L        : INTEGER;
  68.    AA       : PACKED ARRAY[ 1 .. 1 ] OF CHAR ABSOLUTE A;
  69.  
  70. BEGIN (* CopyS2AR *)
  71.  
  72.    Len_S  := LENGTH( S );
  73.    Len_A  := Length_A;
  74.    L      := MIN( Len_A , Len_S );
  75.  
  76.    FOR I := 1 TO L DO
  77.       BEGIN
  78.          AA[Len_A] := S[Len_S];
  79.          Len_A     := Len_A - 1;
  80.          Len_S     := Len_S - 1;
  81.       END;
  82.  
  83.    FOR I := Len_A DOWNTO 1 DO
  84.       AA[I] := ' ';
  85.  
  86. END   (* CopyS2AR *);
  87. ə