File: copy-string.2gg

package info (click to toggle)
golf 601.4.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,824 kB
  • sloc: ansic: 20,020; sh: 1,171; makefile: 292
file content (87 lines) | stat: -rw-r--r-- 1,809 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
copy-string \-  (strings)
.SH PURPOSE
Copies string to another string.

.SH SYNTAX

.RS 4
.EX

copy-string <source string> to <dest string> \\
    [ start-with <start with> ] \\
    [ length <length> ] 

.EE
.RE

.SH DESCRIPTION
Use copy-string to copy <source string> to <dest string>.

<start with> number (in "start-with" clause) is the position in <source string> to start copying from, with 0 being the first byte.

Without "length" clause, the whole of <source string> is copied. With "length" clause, exactly <length> bytes are copied into <dest string>.

You can copy a string to itself. In this case, the original string remains and the new string references a copy:

.RS 4
.EX

set-string str = "original string" // string to change

set-string orig = str // references original copy of the string to change

copy-string str to str // make a copy of string to change and assign it to itself

upper-string str // change the copy

// Now "str" references "ORIGINAL STRING" 
// and "orig" references "original string"

.EE
.RE


.SH EXAMPLES
After copy-string below, "my_str" will be a copy of string "some value":

.RS 4
.EX

set-string other_string="some value"
copy-string other_string to my_str 

.EE
.RE

Copy certain number of bytes, the result in "my_str" will be "ome":

.RS 4
.EX

set-string other_string="some value"
copy-string other_string to my_str length 3 start-with 1

.EE
.RE

.SH SEE ALSO
 Strings

\fBconcatenate-strings\fP  
\fBcopy-string\fP  
\fBcount-substring\fP  
\fBdelete-string\fP  
\fBlower-string\fP  
\fBnew-string\fP  
\fBread-split\fP  
\fBreplace-string\fP  
\fBset-string\fP  
\fBsplit-string\fP  
\fBstring-length\fP  
\fBtrim-string\fP  
\fBupper-string\fP  
\fBwrite-string\fP   
See all 
\fBdocumentation\fP