Method: ParseString for Formatter
- Updated2024-09-12
- 2 minute(s) read
DataPlugin > Methods > Method: ParseString for Formatter
Method: ParseString for Formatter
Parses a text into the specified data type.
vParseString = Object.ParseString(sPString, eDataType)
| Object | Formatter Object with this method | ||||||||||||||||||||||||||||||||||||||||||
| sPString | String Specifies the text to convert. | ||||||||||||||||||||||||||||||||||||||||||
| eDataType | Specifies the data type. Enumeration with the following selection terms:
|
||||||||||||||||||||||||||||||||||||||||||
| vParseString | Variant Receives the converted text. |
| Note If the text is converted to a numeric type, only the first number in the text is used. If the text does not contain a number, the return value is NULL. |
| Note The conversion uses the current format. |
| Note If the data types eU16 or eU32 are returned, the return value ConvString can cause problems in VBS. |
The following example shows how to read strings and to use ParseString to convert the strings into real values.
Dim ChnName : ChnName = File.GetCharacters(120) Dim rChnCount : rChnCount= File.Formatter.ParseString(File.GetCharacters(12), eR64) If IsNull(rChnCount) Then RaiseError Dim rChnDelta : rChnDelta= File.Formatter.ParseString(File.GetCharacters(24), eR64) If IsNull(rChnDelta) Then RaiseError Dim rChnMin : rChnMin = File.Formatter.ParseString(File.GetCharacters(24), eR64) If IsNull(rChnMin) Then RaiseError Dim oMyGrp : Set oMyGrp = Root.ChannelGroups.Add("MyChannelGroup") Dim oMyChn : Set oMyChn = oMyGrp.Channels.AddImplicitChannel("Time", rChnMin, rChnDelta, rChnCount, eR64)
The following example shows how to read strings and to use ParseString to convert the strings into time values.
Dim oMyDate : Set oMyDate= File.Formatter.ParseString(File.GetCharacters(20), eTime) If IsNull(oMyDate) Then RaiseError Call Root.Properties.Add("Year/Month", oMyDate.Year&"/"oMyDate.Month)