
60
2.0 Getting Started
The above script makes Link*One filter all input data that doesn’t start
with the characters K06.
2.10.13.8 Input Data Replacements
The replacement function in earlier WLinq versions was quite easy to
use. But it lacked power and flexibility. Below is an example of a simple
substring replacement. It replaces all occurrences of the character K
with the character X.
Multiple replacements can be done by storing the result in a string vari-
able and repeat the process. Here K is replaced with X and A is replaced
with TEST.
2.10.13.9 Criteria
In the previous WLinq generation, a data format was activated for a data
string when the criteria of the data format matched. Two types of crite-
ria were supported, length and pattern.
In Link*One the same function as a length criteria is implemented using
an if-statement.
An alternative approach could be:
A pattern criteria like the one above could be implemented using the
string.find() pattern matching method:
The format used for patterns in string.find() and the format in WLinq
3.x is different. Please refer to the Lua documentation for the Lua pat-
tern format.
A big advantage with scripting in Link*One is that more complex deci-
sions can be made, for example mixing length and pattern matching,
something that was not possible in WLinq 3.x. Multiple criteria used in
WLinq 3.x can be implemented by chaining if-elseif-statements:
2.10.13.10 Data Format Output
In a WLinq 3.x data format, expressions was entered into the data format
output edit box and combined with plus (+). In Link*One, all the string
operations are using the facilities of the embedded script language. To
make Link*One simulate a possibly modified string as keyboard output,
you need to pass the string to the method
app.send()
.
Use the table below as a guide for converting expressions in WLinq 3.x
to Link*One. Most string operations in WLinq 3.x operated on the data
input string implicitly. In Link*One, the data string is an argument sent
to the script methods
onData()
,
onKeyboardCapture()
, and
on-
ExternalData()
.
Constant String
WLinq 3.x
Link*One
“ABC”
“ABC”
Extract a substring from the start of the string
WLinq 3.x
Link*One
Left( 3 )
string.sub( data, 1, 3 )
string.sub( data, -3 )
WLinq 3.x
Link*One
Right( 3 )
string.sub( data, -3 )
Extract characters from position three up to position four.
Please note the difference in parameters!
WLinq 3.x
Link*One
Mid( 3, 2 )
string.sub( data, 3, 4 )
From the first A in the string, extract five characters includ-
ing the A
WLinq 3.x
Link*One
Mid( “A”, 5 )
string.gsub( data, “.*(A....).*”, “%1” )
Extracts characters from position six to the end of the string
WLinq 3.x
Link*One
Mid( 6 )
string.sub( data, 6 )
Scans for the first string and extracts all characters up to
the second string.
23 and CD is not included in the result.
WLinq 3.x
Link*One
SubStr( “23”, “CD” )
string.gsub( data, “.*23(.*)CD.*”, “%1” )
The entire data string
WLinq 3.x
Link*One
Input()
data
Inserts the current date in the specified format
WLinq 3.x
Link*One
Date( “%Y-%m-%d” )
os.date( “%Y-%m-%d” )