Um String Code 2 0 e
Um String Code 2 0 e
v2.0
Contents
Contents
Contents ............................................................................ 2
Syntax ................................................................................ 6
3.1
Keywords ..................................................................................... 6
3.1.1
3.1.2
3.1.3
3.1.4
3.1.5
3.1.6
3.1.7
3.2
3.3
3.4
3.5
3.6
3.7
3.7.1
3.7.2
3.7.3
3.7.4
3.7.5
3.8
3.8.1
3.8.2
3.8.3
3.8.4
3.8.5
3.8.6
3.8.7
3.9
History ............................................................................. 29
5.1
5.1.1
5.1.2
5.1.3
5.1.4
E.g. 1 ................................................................................................. 30
E.g. 2 ................................................................................................. 30
E.g. 3 ................................................................................................. 31
E.g. 4 ................................................................................................. 31
5.2
v2.0
11.12.08
Contents
5.2.3 E.g. 7................................................................................................. 33
5.2.4 E.g. 8................................................................................................. 34
5.2.5 E.g. 9................................................................................................. 34
5.3
5.4
5.5
5.6
5.6.1
5.6.2
5.6.3
5.6.4
5.6.5
5.6.6
5.6.7
5.7
11.12.08
E.g. 13............................................................................................... 40
E.g. 14............................................................................................... 40
E.g. 15............................................................................................... 40
E.g. 16............................................................................................... 41
E.g. 17............................................................................................... 42
E.g. 18............................................................................................... 42
E.g. 19............................................................................................... 42
v2.0
In GEOPAK, you can insert different information of a part program in a text line.
file identifications,
element names,
formula calculation,
text output,
proposals for input in UDL-Dialogs (since v2.1R1)
Var1 = @StrLen(Text)+1
Var1 = 4+1
Var1 = 5
v2.0
11.12.08
In addition since the v2.1.R1 stands in the command "Define Text Variable" a
complete list "Stringcoding" at disposal.
11.12.08
v2.0
Syntax
Syntax
3.1
Keywords
@ElementName[PT,1]
@ElementName [PT, 1]
@ElementName [ PT , 1 ]
etc.
@StrGetNum("x;y;Z",";","1")
3.1.1
@Time:#:#:#
@Date:#:#:#
@Hour:#:z
Actual hour
@Minute:#:z
Actual minute
@Second:#:z
Actual seconds
@MilliSecond:#:z
Actual milliseconds
@Year:#:z
Actual year
@Month:#:z
Actual month
@Week:#:z
Actual week
@DayOfYear:#:z
@DayOfWeek:#:z
@Day:#:z
Actual day
@TimeCode:#:#:#
@SecToTime(xxx) :#:#:#
3.1.2
Access Variables
@(VarName):#:#:z
@(VarName:#:#:z)
@[TxtVarName]:#:#:#
@[TxtVarName:#:#:#]
@Formula(x):#:#:z
Value of a variable
@Formula(x):#:#:z
v2.0
11.12.08
Syntax
Controlled if a variable exist.
@ResVarExist("VarNam")
@StrVarExist("VarNam")
3.1.3
@StrLen(Text):#:z
@StrLen(Text):#:z
@StrPos(Text,Such-Text):#:z
@StrPos(Text,SuchText):#:z
@StrLeft("Text","Pos")
@StrRight("Text","Pos")
@SubStr("xxx","no1","no2")
@StrChg("Text","from","to")
@StrChgAll("Text","from","to")
@StrGetStr("Text","sep","num")
Str1 = @StrGetStr("Thomas;Peter;Frank",";","1")
= Thomas
Str2 = @StrGetStr("Thomas;Peter;Frank",";","2")
= Peter
Str3 = @StrGetStr("Thomas;Peter;Frank",";","3")
= Frank
Separate and returns a number string from a
CSV string.
E.g.:
Str1 = @StrGetNum("0.123;4.567;8.900",";","1")
@StrGetNum("Text","sep","num
= 0.123
")
Str1 = @StrGetNum("0.123;4.567;8.900",";","2")
= 4.567
Str1 = @StrGetNum("0.123;4.567;8.900",";","3")
= 8.900
11.12.08
v2.0
Syntax
Test if a file, specified by FileName, exists or
not. Returns 1 in case of existing and 0 in
case of not existing.
@FileExist("FileName")
E.g.:
Str1 =
@FileExist("C.\Cosmos\Temp\Variable.Res")
Compares two strings (case sensitive). The
return value for each of these functions indicates
the lexicographic relation of xxx to yyy.
@StrCmp("xxx","yyy")
@StrICmp("xxx","yyy")
3.1.4
@Partname:#:#:#
@PartProgname:#:#:#
@Revision:#:z
@Operator:#:#:#
@OperatorLevel:#:z
@RC:#:z
Repeat counter
@LC:#:z
Loop counter
@NoOfLC:#:z
@LoadedVars
@ErrNoText[x]:#:#:#
@ElementName[type,x]:#:#:#
v2.0
11.12.08
Syntax
@OutText[x]:#:#:#
3.1.5
Access Sublot
@SubLot:#:#:#
Sublot
@SubLotF*:#:#:#
3.1.6
@HeadDataF*:#:#:#
@HeadData[*]:#:#:#
3.1.7
@PartDrive:#:#:#
@PartDirectory:#:#:#
@PartPath:#:#:#
@PartSubDirectory
@CosmosDrive:#:#:#
@CosmosDirectory:#:#:#
@CosmosPath:#:#:#
@CosmosTempPath:#:#:#
@CosmosAudioPath:#:#:#
COSMOS Audio-Path
@CosmosPicturePath:#:#:#
COSMOS Picture-Path
@CosmosProbePath:#:#:#
@CosmosProbeArchivPath:#:#:#
@CosmosCoordPath:#:#:#
@CosmosCoordArchivPath:#:#:#
@CosmosLayoutPath:#:#:#
@CosmosTransferPath:#:#:#
3.2
11.12.08
Formatting Options
v2.0
Syntax
:#:z
:#:#:z
:#
10
v2.0
11.12.08
Syntax
3.3
In the following you can see an example for the real application of a text variable.
The user has the task to enter the name of an output file. This can
be done when starting the part program.
To continue the run of the part program, the defined string variable FileName
can be used in the File Format Specification function.
11.12.08
v2.0
11
Syntax
12
v2.0
11.12.08
Syntax
3.4
11.12.08
v2.0
13
Syntax
Result:
3.5
14
v2.0
11.12.08
Syntax
Result:
3.6
Here, the name of circle elements should be continually generated in a selfacting way for example Kr001, Kr002, Kr003 etc..
What do we have at our disposal?
11.12.08
v2.0
15
Syntax
3.7
In this example, suppose that we read in an ASCII-file with three lines containing
per line three values for one measurement point, namely X, Y and Z. The three
measurement points are supposed to be measured.
The fixed format is as follows (also refer to help line below):
01. to 10. sign contains the X-value
11. to 20. sign contains the Y-value
21. to 30. sign contains the Z-value
The ASCII file that must be read in could be as follows:
10.01
11.02
0.03
20.01
12.02
0.03
30.01
13.02
0.03
3.7.1
Read in File
First, the file with the Load String Variables function must be read in. The string
variable name is specified with ReadData (also see chapter 5.5):
16
ReadData0=
10.01
11.02
0.03
ReadData1=
20.01
12.02
0.03
ReadData2=
30.01
13.02
0.03
v2.0
11.12.08
Syntax
3.7.2
Now, the single values are read from within the string variables. Because several
lines must be evaluated, the best would be to use a loop.
Terms like @FORMULA(@LC-1):0 would have in the first loop flow a return 0,
in the second 1 and in the third 2. Access to a name-incremental string
variable should therefore look as follows:
@[ReadData@FORMULA(@LC-1):0]
Since the version v2.3.R1 you can use the command
"@StrGetStr("Text","sep","num")".
3.7.3
Filter Section
Now, we know the contents of the read in string variable and we only must filter a
specific section:
@[ReadData0]:0:10:1
@[ReadData0]:0:10:11
@[ReadData0]:0:10:21
3.7.4
11.12.08
v2.0
17
Syntax
Now, you can use these variables as usual for the position
in a measurement as well as
you can complete the loop (see dialogue below):
3.7.5
18
v2.0
11.12.08
Syntax
3.8
3.8.1
In this example, an ASCII file with several lines must be read in containing three
values per line for one measurement point, namely X, Y and Z. The three values
are separated from one another by a separation sign.
The format is as follows and has a semicolon as a separation sign:
X-value; Y-value; Z-value
The ASCII file that must be read in could be as follows:
10.01;11.02;0.03
20.1;12.2;0.3
30.01;13.02;0.03
40.1;14.2;0.3
50.01;15.02;0.03
3.8.2
Read in File
First, the file with the Load String Variables function must be read in. The string
variable name is specified with ReadData (also see chapter 1.3.6):
11.12.08
v2.0
19
Syntax
3.8.3
Now, the single values within the string variables are read. Because several lines
must be evaluated, the best would be to use a loop.
Because the number of the lines already read in has not been specified, this is
determined through the @LOADEDVARS keyword:
3.8.4
To get a clear overview, the line, which was read in is buffered. Terms like
@FORMULA(@LC-1):0 would occasion the return 0 in the first loop flow, in
the second 1 and in the third 2 etc..
Access to a name-incremental string variable should therefore look as follows:
@[ReadData@FORMULA(@LC-1):0]
Since the version v2.3.R1 you can use the command
"@StrGetStr("Text","sep","num")".
20
v2.0
11.12.08
Syntax
3.8.5
Filter a Section
Now, we have the total contents of the string variable, which was read in, and
only another specified section must be filtered. To achieve this, we must locate
the positions of the first separation sign:
@STRPOS(@[Dummy],;)
Now, the first value can be filtered. Direct inserting of the CutPos string variable
would certainly provide one sign too much:
@[Dummy:0:@[CutPos]]
->
10.01;
->
11.12.08
v2.0
10.01
21
Syntax
3.8.6
Now, we must abridge the first part of the string variable that was read in.
The formatting part must cut the rest of the term beginning from the separation
sign plus one:
:0:@STRLEN(@[Dummy]):@FORMULA(@[CutPos]+1):0
-> :0:16:7
And inserted:
@[Dummy:0:@STRLEN(@[Dummy]):@FORMULA(@[CutPos]+1):0]
Now, the same procedure is realized, as above, extract and cut once again:
22
v2.0
11.12.08
Syntax
3.8.7
Variable as Position
11.12.08
v2.0
23
Syntax
3.9
3.9.1
In a fully automatic operation, a part program must be repeated. However, not all
elements in the part program must be measured. This must be decided via a
central server. The server writes a single-line file for each repetition. In the file,
identifiers such as A, B, C and D determine what must be measured.
The ASCII file that must be read in could be as follows:
ABCD
or
BCD
or
ACD
or
ABC
etc.
24
v2.0
11.12.08
Syntax
3.9.2
The rest is only done in the editor. Because the control file contains the singleline information, what is to be measured, it is loaded at the beginning of the part
program with the command
Load String Variables as well as the options
Wait for File and
Delete File.
11.12.08
-> e.g.: 1
v2.0
25
Syntax
26
@STRPOS(@[Cx0],B)
-> e.g.: 2
@STRPOS(@[Cx0],C)
-> e.g.: 0
@STRPOS(@[Cx0],D)
-> e.g.: 3
v2.0
11.12.08
Syntax
Then, the cut-out of the part program looks as follows:
11.12.08
v2.0
27
Syntax
The Load String Variable function is suitable for format descriptions, formula
collections or similar. This is due to the read in particularity. The read in contents
are not directly analysed, but rather is taken as a result.
If e.g. the following is read in:
String=@(Value):8:3:z
Here, String is the Variable and @(Value):8:3:z the content.
Later, this variable is set in a function:
Output Text Function: @[String]
3.10.2
First of all, and not visible for the user, the result is inserted. In this case:
Output Text function: =@(Value):8:3:z
Only then, analysis continues (e.g. value = 0.01):
Output Text Function: =0000.010
Knowing this, material collections, formula collections or format descriptions are
assembled now.
E.g. for correction data:
XvalStr=@(CalcX):8:3:z
YvalStr=@(CalcY):8:3:z
ZvalStr=@(CalcZ):8:3:z
EOutPut=E-@PartProgName:-20 X@[XvalStr] Y@[YvalStr]
Z@[ZvalStr]
Here, you must specify that the correction data are calculated in CalcX, CalcY
and CalcZ in the part program.
28
v2.0
11.12.08
History
History
Report
What?
Version
V 2.0
GEOPAK v3.1.R1
V 1.9
Chapter. 2
@ElementName[et,x],
@OutText[x]
GEOPAK v3.0.R1
V 1.8
Chapter. 2
@StrCmp("xxx","yyy"),
@StrICmp("xxx","yyy"),
@SubStr("xxx","no1","no2")
GEOPAK v2.4.R1
V 1.8
Chapter. 2
@FileExist("FileName")
GEOPAK v2.4.R1
V 1.70
Chapter. 2
@StrLeft("Text","Pos"),
@StrRight("Text","Pos"),
@StrChg("Text","from","to"),
@StrChgAll("Text","from","to"),
@StrGetStr("Text","sep","num"),
@StrGetNum("Text","sep","num")
GEOPAK v2.3.R1
V 1.60
Chapter. 2
@Week, @DayOfYear,
@ErrNoText[No]
GEOPAK v2.1.R1
V 1.50
Chapter 3
Chapter changed
V 1.50
Chapter 2
@PartSubDirectory,
@LoadedVars
GEOPAK v1.5.R1
V 1.10
Chapter 2
@StrLen(x) , @StrPos(x,y),
@Formula(x), @Formula(x),
@SecToTime(x), @PartDrive,
@PartDirectory, @PartPath,
@CosmosDrive,
@CosmosDirectory,
@CosmosPath,
@CosmosAudioPath,
@CosmosPicturePath,
@CosmosProbePath,
@CosmosProbeArchivPath,
@CosmosCoordPath,
@CosmosCoordArchivPath,
@CosmosLayoutPath,
@CosmosTransferPath,
@CosmosTempPath
GEOPAK v1.5.B2
V 1.04
Chapter 2
@StrLen(x), @StrPos(x,y)
GEOPAK v1.5.A17
V 1.03
Chapter 2
GEOPAK v1.5.A16
V 1.02
Chapter 2
GEOPAK v1.5.A13
V 1.01
Chapter 2
@PartProgName, @Operator,
@[String], @HeadDataF#,
@HeadData[#]
GEOPAK v1.5.A2
V 1.00
Chapter 2
GEOPAK v1.5.A14
11.12.08
v2.0
29
5.1
5.1.1
E.g. 1
5.1.2
E.g. 2
v2.0
11.12.08
5.1.3
E.g. 3
Assume that we need to deal with a component serial number of the following
format...
000123456
Trying to handle this as a numeric variable would remove the leading zeros, so
that the sequence: <Formula Calculation>
Name of variable = Number
Formula = 000123456
<Text to Screen> @(Number) now displays 123456
5.1.4
E.g. 4
11.12.08
v2.0
31
5.2
Variables can be obtained from external sources by reading them into GeoWin from a file.
The mechanism employed for reading in string variables is basically identical
to that for reading in numeric variables.
Care should be taken to ensure that the format of the file contents is well
defined, prior to using this form of input.
Care should be taken to ensure that the variables are read in as the correct
type (string or numeric).
All of the files contents are taken in during the read operation, partial input is
not possible.
A file can only be read in as all string or all numeric, the types of input
cannot be mixed within one file.
The variables names may be assigned within the file, determined
automatically by Geo-Win, or sequentially assigned during the read in
operation.
Geo-Win assumes the following extensions for variable files, but will accept
any filename and extension
Numeric VariablesRES
String Variables
STR
5.2.1
E.g. 5
1111
02222
3333
4444
ABCD
The sequence <Calculate> <Load Variables from File> will prompt for the file
to be used for input. Simple entry of C:\Data\MyData.ASC as the path and
filename will automatically read in the file contents as numeric variables of the
following names
RES0 = 1111.000 RES1 = 2222.000 RES2 = 3333.000 RES3 = 4444.000
The operation will conclude with a variable not defined error.
Notice the following points;
1. The name RES has been automatically assigned
2. The name RES has been automatically appended with a sequential
number
3. The sequential numbering always starts from zero
4. The leading zero has been dropped from RES1 to make a valid number
5. All values are displayed to the set number of decimal places
6. The variable not defined error occurred due to the fifth piece of data in
the file ABCD, which was not numeric and therefore failed to be assigned
to RES4
32
v2.0
11.12.08
5.2.2
E.g. 6
1111
02222
3333
4444
ABCD
The sequence <Calculate> <Load String Variables> will again prompt for the
file to be used for input. Simple entry of C:\Data\MyData.ASC as the path and
filename will automatically read in the file contents as String variables of the
following names
STR0 = 1111 STR1 = 02222 STR2 = 3333 STR3 = 4444 STR4 = ABCD
Notice the following points;
1. The same data file was used for both types of input, but achieved different
results
2. No error was reported at conclusion of the operation
3. The name STR has been automatically assigned
4. The name STR has been automatically appended with a sequential
number
5. The sequential numbering always starts from zero
6. All data has been taken in, exactly as contained in the file
7. Decimal places have not been appended, because the data is not
numeric
5.2.3
E.g. 7
1111
02222
3333
4444
ABCD
The sequence <Calculate> <Load Variables from File> will prompt for the
file to be used for input. Entry of C:\Data\MyData.ASC as the path and filename
followed by selection of <Load Filter>, with an entry of Figure will automatically
read in the file contents as numeric variables of the following names
Figure0 = 1111.000 Figure1 = 2222.000 Figure2 = 3333.000 Figure3 = 4444.000
The operation will again conclude with a variable not defined error due to the
fifth piece of data not being numeric.
Repetition of the preceding sequence, with substitution of Figure7 for Figure
will modify the resultant data as follows
11.12.08
v2.0
33
5.2.4
E.g. 8
C:\Data\MyData.ASC
Feature1 = 1111
Feature2 = 02222
TestOut
Size = 3333
Weight = 4444
Name = ABCD
EFGH
The sequence <Calculate> <Load String Variables> will again prompt for the
file to be used for input. Simple entry of C:\Data\MyData.ASC as the path and
filename will automatically read in the file contents as String variables of the
following names
Feature1 = 1111 Feature2 = 02222 STR2 = TestOut Size = 3333 Weight = 4444
Name = ABCD STR6 = EFGH
Notice the following points;
1. The variables name may be assigned within the file, using the = symbol
2. Numbering may also be attached to the name
3. Variable names may be mixed within one file
4. Although not recommended, it is possible to have some of the variables
named within a file and others not. In this case, those named have the
name assigned within the file, those not named within the file are
assigned the default name (STR for strings or RES for numerics) with a
count appended equal to its position within the file (starting from position
zero)
5. The same mechanism, of applying the variables name within the file, is
also applicable to numeric variables
5.2.5
E.g. 9
34
v2.0
11.12.08
11.12.08
v2.0
35
5.3
36
v2.0
11.12.08
5.4
5.4.1
E.g. 10
Assume a numeric variable, called Number containing the value of 0.12345 and
the system is set for resolution to three decimal places.
Giving the commands <Machine> - <Move Machine> and entering the X value as
Number will show that it has moved the machine 0.123.
Similarly, giving the command <Text to Screen> and entering the text as I
moved @(Number)
Displays I moved 0.123 on the screen.
Formatting the numeric variable by succeeding the name, in parentheses ( ), with
a colon : and a value # overrides the number of decimal places the variable is
displayed at as per the following table
Displayed Text
no decimal places
1 decimal place
3 decimal places
5 decimal places
11 decimal places
I moved 0
I moved 0.1
I moved 0.123
I moved 0.12345
I moved 0.12345000000
The formatting option is not accepted within a numeric field input (e.g. Move
Machine) as the number of decimal places is governed by system resolution.
Placing the value # inside the parentheses ( ) will give the same effect, i.e.
I moved @( Number:11) 11 decimal places
I moved 0.12345000000
Placing a second colon : and value # within the parentheses ( ) allows the text
output to be formatted with leading spaces prior to the display of the value
and number of decimal places
5.4.2
E.g. 11
Displayed Text
I moved @(Number:7:5)
I moved @(Number:8:5)
I moved @(Number:20:5)
places
11.12.08
v2.0
37
5.4.3
E.g. 12
Displayed Text
I moved @(Number:9:6:z)
use leading zeroes
I moved @(Number:8:5:z)
use leading zeroes
I moved @(Number:11:5:z)
& leading zeroes
I moved 00.123450
I moved 00.12345
5.5
38
v2.0
11.12.08
X position hole 1
Y position hole 1
Z position hole 1
Diameter hole 1
X position hole 2 etc.
-10.000
-10.000
-1.000
14.000
-10.000
10.000
-2.000
20.000
10.000
10.000
-3.000
25.400
10.000
-10.000
-4.000
34.925
Part - Program:
1.
Change Probe
2.
3.
C:\COSMOS\TEMP\MEASURE.RES
The path and filename are totally user defined however, it is good practice to use the dot RES extension for numeric variable files. A Load
Filter was set to Feature so that the contents are automatically named as Feature0, Feature1 Feature8 etc. as they are read into Geo-Win.
4.
CNC on/off
ON
5.
Clearance Height
Clearance height ON
Z axis = 10.000
An example arbitrary clearance height has been set, to eliminate intermediate points and reduce program size.
6.
Formula Calculation
Count = @LoadedVars/4
The @LoadedVars is a system variable that automatically keeps count of how many variables have been read in from the file. Knowing that there
are 4 entries in the file for each hole, dividing this figure by 4 means that the variable Count can be used to determine how many holes have to be
measured.
7.
Loop Start
Start the loop, to run the same number of times as there are holes.
8.
Formula Calculation
PosX
= @(Feature@Formula(@LC*4-4):0)
9.
Formula Calculation
PosY
= @(Feature@Formula(@LC*4-3):0)
Variable PosY was the second piece of data in each group of 4 variable sets.
Therefore, the only difference is the statement @LC*4-3 (one less) which therefore gives us the answer 1.000
The remainder of the statement is as explained above, so that our formula is PosY = Feature1 The second variable.
PosZ
= @(Feature@Formula(@LC*4-2):0)
If you have followed the above, you will see that in the first run of the loop the statement gives .
PosZ = Feature2 The third variable.
When the loop runs the second time LC = 2, so @LC*4-2 comes out as
2 times 4 equals 8, minus 2 equals 6
so the statement gives PosZ = Feature6 the seventh variable and Z position for the second hole.
Diam
= @(Feature@Formula(@LC*4-1):0)
Same technique as above, but for the diameters. First loop run gives Feature3, second gives Feature7, fourth gives Feature15 to extract the
diameters.
13. Circle
Mean
Hole@Formula(CR.MaxNo+1):3:0:z
(1)
OFF
It is recommended, by CTL-G, to remember to switch OFF CNC at the end of every part program.
11.12.08
v2.0
39
5.6
We are already aware that we can read in, or display string variables, in a similar
manner to numeric variables. It is also possible to concatenate string variables
(concatenation simply means join together).
5.6.1
E.g. 13
5.6.2
E.g. 14
5.6.3
E.g. 15
40
In its simplest form, the statement @StrPos(ABCDE,C) will return the value 3
(the first position of C within the string).
The statement @StrPos(ABCDEC,C) will still return the value of 3, the first
position of C found, any subsequent occurrences are ignored.
v2.0
11.12.08
5.6.4
E.g. 16
v2.0
41
5.6.5
E.g. 17
<Define String Variable> Str0 = Succeed
<Text to Screen>
The portion is@[Str0:3:2:3]
Displayed result is
The portion is cc
This has simply told Geo-Win to display the word Succeed (@[Str0]) using 3
character places (@[Str0:3]) and display just 2 of its characters (@[Str0:3:2])
starting from character number 3 (@[Str0:3:2:3]) so it has displayed the
characters cc appended straight onto the end of The portion is but effectively
leaving one space, because it was told to use 3 character spaces.
If the statement had been @[Str0:2:2:3] it would have displayed The portion
iscc, closed up without spaces, alternatively if the statement read @[Str0:8:2:3]
the corresponding display would have used 8 character spaces for the string
portion displayed thus The portion is
cc leaving 5 blank spaces in between.
Going back to the original statement @[Str0:3:2:3], if it is modified at the second
formatting value thus @[Str0:3:1:3] the resultant display would append only the
character c, whereas changing the statement to @[Str0:3:4:3] would append
the characters ccee.
Finally, from the original statement @[Str0:3:2:3], if the last formatting value is
modified so the statement reads @[Str0:3:2:1] it would append the characters
Su, whereas altering the statement to @[Str0:3:2:6] would append the
characters ed.
Explanation has already been given of string concatenation and now string
formatting. The formatting functions are, as with numeric variables, useful for
generating output in given text or file formats. The basic understandings of
formatting options are however much more useful if applied to extracting substrings from a parent string variable.
5.6.6
E.g. 18
Let
Str0 = Fredrickson
Then the statement Str1 = @[Str0:0:1:4] gives d
Similarly
Str2 = @[Str0:0:3:6] gives ick
Therefore, using the above sub-string extraction technique along with
concatenation
The statement
Str3 = @[Str0:0:1:4]@[Str0:0:3:6] gives dick
Whilst the above may be considered agreeable options, merely of interest for
output, it should be realised that they provide the user with a very powerful set of
tools that expand on the capability of just using numeric variables manifold.
5.6.7
E.g. 19
Lets reconsider the serial file format of example 9. The contents of the file were
as follows;
1111;02222;3333;4444;ABCD
42
v2.0
11.12.08
11.12.08
v2.0
43
44
A string variable Pointer is used to locate the position of the first colon in
the string. A string, rather than a numeric variable, is used because we
need to embed the result within a formatting statement and such
statements are not numeric, so would cause a failure.
Pointer = @StrPos(@[Str0],;) simply says Find the position of the colon
within Str0 and assign that value, as a string, to Pointer.
Res0 = @[Str0:0 says Assign a portion of string Str0 to numeric Res0, as
a numeric variable with no decimal places.
We next need to know how many characters it consists of.
We have the position of the colon in the string variable Pointer so the
number of characters must be one less than this value.
(@[Pointer]) converts the string to a numeric so that we can subtract one
from it, with the statement (@[Pointer]-1).
This statement however is a numeric calculation that must take place
within a string, so we precede it with the keyword @Formula to allow this
to happen, making the statement
Res0 =
@[Str0:0:@Formula(@[Pointer]-1).
Knowing how many characters to collect is fine but, we need to know
where to start to collect them from.
As its from the start of the string, appending the statement :0 says Start
from position zero and the closing ] is needed because it is a string we
are evaluating.
So, the whole statement is Res0 = @[Str0:0:@Formula(@[Pointer]-1):0].
Substituting the values for the first portion we are extracting would show
the statement as Res0 = @[1111;02222;3333;4444;ABCD:0:4:0] =
1111. The statement, in this exact format, would not work. It is presented
in this manner to aid clarification of meaning only.
The preceding operation has not removed 1111 from Str0, it has simply
made a copy of that portion. As searching the string only comes up with
the first occurrence of what is being searched for, we need to remove the
first portion of the original string up to, and including the first colon, so that
it will successfully find the next.
The statement Str0 = @[Str0] would say Modify Str0 to contain what is in
Str0, a pointless statement in itself, because it changes nothing.
However, if we were to say Modify Str0 to contain what is in Str0 less
some portion of it the effect would be to reduce its contents. This is what
we want to do but, which portion and how to do it?
Remember, strings are not numeric so you can not add them, or take
them away from each other, you can only concatenate (join them), or
extract sub-strings (cut them). We need to extract a sub-string that is
equal to what is left after the first colon. We already know the position of
the colon (Pointer), so lets see how we do it.
The
statement
Str0
=
@[Str0:0:@StrLen(@[Str0]):@Formula(@[Pointer]+1):0] does just that
job.
Str0 = @[Str0:0 says some portion of Str0 with a minimum of zero
spaces (use what space is needed).
How many characters? The full length of Str0 (:@StrLen(@[Str0])).
Starting from which character? One after the colon (@[Pointer]+1), but
this needs to be calculated within the formatting statement, so precede it
with @Formula and put it in parentheses to make it numeric
(:@Formula(@[Pointer]+1)).
v2.0
11.12.08
11.12.08
v2.0
45
5.7
Potential Uses
Following are some obvious, and some less obvious, application uses. It is up to
the individual, with reference to the guidance documentation mentioned earlier, to
put it to practical use.
a) A program could be generated, consisting of a subroutine for each element or
operation. A string could be sent, at the start of the program, which could be
evaluated and tested for which feature (part derivative to measure). I.e. String
1 says measure A B C F G
String 2 says measure C G H
b) The earlier example generic hole program which used only numeric
variables, could be modified to take the data in serial format. Now, each line
could contain the data for the complete hole (including name, tolerances
etc.). One line per feature would eliminate the need to calculate the number
of features for the loop, it would correspond to the number of lines within the
file.
c) Control and communication with external devices is easily realised, with
message test capabilities embedded within the part program.
d) It should now be possible, with some time and effort invested, to produce a
generic virtual part program.
Create sub-routines for each CMM operation or command
Create a data file that includes, on each single line, not only the relevant
data but the type of CMM command to be used (IP, CR, TO, CP, IH etc.)
Create a virtual part program that reads each line of the file, as a string
Extract the type of command from the start of the string
Extract the relevant components for that command, call the sub-routine
and apply them (you may never have to program again!)
Note: Although it must be stressed that the author has had no opportunity to
attempt the following suggestion, it is quite probable that the format of
simple CAD files could be successfully directly processed, within a GeoWin part program, by absorbing and processing as string variables.
46
v2.0
11.12.08