64
(and therefore has number 1); the character matching "." is captured with number 2, and the part
matching "%s*" has number 3.
As a special case, the empty capture () captures the current string position (a number). For
instance, if we apply the pattern "()aa()" on the string "flaaap", there will be two captures: 3 and
5. A pattern cannot contain embedded zeros. Use %z instead.
1.2.19.
Input and output functions
io.exists (path)
Checks if given path (file or directory) exists. Return boolean.
io.readfile (file)
Reads whole file at once. Return file contents as a string on success or nil on error.
io.writefile (file, data)
Writes given data to a file. Data can be either a value convertible to string or a table of such
values. When data is a table then each table item is terminated by a new line character. Return
boolean as write result when file can be open for writing or nil when file cannot be accessed.
Example: Write event status to log file located on plugged USB flash drive:
1.
value
=
knxdatatype.decode
(
event.datahex, dt.bool
)
2.
data
=
string.format
(
'%s value is %s'
,
os.date
(
'%c'
)
,
tostring
(
value
))
3.
-- write to the end of log file preserving all previous data
4.
file
=
io.open
(
'/mnt/usb/log.txt'
,
'a+'
)
5.
file:
write
(
data ..
'
\r\n
'
)
6.
file:close
()
Output:
Mon Jan 3 05:25:13 2011 value is false
Mon Jan 3 05:25:14 2011 value is true
Mon Jan 3 05:25:32 2011 value is false
Mon Jan 3 05:25:33 2011 value is true
Example: Read data from file (config in format key=value)
1.
for
line
in
io.lines
(
'/mnt/usb/config.txt'
)
do
2.
-- split line by '=' sing
3.
items
=
line:split
(
'='
)
4.
-- two items, line seems to be valid
5.
if
#items
==
2
then
6.
key
=
items
[
1
]
:trim
()
7.
value
=
items
[
2
]
:trim
()
8.
alert
(
'[config] %s = %s'
, key, value
)
9.
end
10.
end
1.2.20.
Script control functions
script.enable('scriptname')
Содержание LogicMachine3 Re:actor
Страница 10: ...10 Terminal connection schemes KNX TP...
Страница 12: ...12 24V power supply...
Страница 13: ...13 Analog inputs e g reed contact...
Страница 14: ...14 Analog inputs 0 10V...
Страница 15: ...15 Digital output...
Страница 16: ...16 Resistive sensor input...
Страница 17: ...17 Analog output...
Страница 26: ...26 Make sure that bus status is Online press button in ETS...
Страница 35: ...35 o Then minimize side bar by pressing on left arrow icon to make the map more visible...
Страница 83: ...83 66 if err then 67 alert FTP upload failed s err 68 end...
Страница 107: ...107...
Страница 108: ...108 1 14 Help Documentation for scripting syntaxes is displayed in Help tab...
Страница 122: ...122 4 16 Running processes System running processes can be seen in Status Running processes window...
Страница 126: ...126 Datapoints can be shown also in a way of table which can be later exported as CSV file...
Страница 141: ...141...