File: inline-code.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 (86 lines) | stat: -rw-r--r-- 1,643 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
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
inline-code \-  (language)
.SH PURPOSE
Inline Golf code in an output statement.

.SH SYNTAX

.RS 4
.EX

<<golf code>>

.EE
.RE

.SH DESCRIPTION
You can write Golf statements within an \fBoutput-statement\fP by using them between << and >> delimiters. 

The following statements can be inlined: \fBprint-out\fP,\fBprint-format\fP, \fBcurrent-row\fP, \fBnumber-string\fP, \fBstring-length\fP, \fBcall-handler\fP.

.SH EXAMPLES
\fBprint-out\fP statement displays a string, and in the following code it's used to display a result within an \fBoutput-statement\fP (i.e. within "@" statement):

.RS 4
.EX

run-query ="select firstName, lastName from people" output firstName, lastName
   @<tr>
   @    <td>
   @        First name is <<print-out  firstName>>
   @    </td>
   @    <td>
   @        Last name is <<print-out lastName>>
   @    </td>
   @</tr>
end-query

.EE
.RE

In the code below, "some_req" is a request handler that outputs some text, and it's used inline to output "Hello world":

.RS 4
.EX

@Hello <<call-handler "/some-req">> 

.EE
.RE

\fBcall-handler\fP "some-req" would simply output "world":

.RS 4
.EX

%% /some-req public
    @world 
%%

.EE
.RE

A \fBwrite-string\fP is typically used with output statements; in this case we print the value of another string, resulting in "There is 42 minutes left!":

.RS 4
.EX

set-string mins="42"
(( my_string
@There is <<print-out mins>> minutes left!
))

.EE
.RE

.SH SEE ALSO
 Language

\fBinline-code\fP  
\fBstatements\fP  
\fBsyntax-highlighting\fP  
\fBunused-var\fP  
\fBvariable-scope\fP   
See all 
\fBdocumentation\fP