Announcement

Collapse
No announcement yet.

Simple split script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Simple split script

    Hi,

    I need to split my device name in a script, the device name is Dryer Status.
    I simply need to take the 'Dryer' part into a variable.

    So far, I am passing a device's ref ID as a parameter.
    The script takes that parameter and looks up the current status of the device for use in the script later on and also looks up the device name from the same parameter.
    I need to split it rather than rename my devices. Currently, 'DeviceName holds the name of the device but I don't know how to split the first word using space as the delimiter.

    Public Sub Main(ByVal Parms As String)
    Dim DeviceStatus As String
    Dim DeviceName As String
    Dim Device As Scheduler.Classes.DeviceClass
    DeviceStatus = hs.CAPIGetStatus(Parms).Status()
    Device = hs.GetDeviceByRef(Parms)
    DeviceName = Device.name(hs)

    Any help appreciated.


    #2
    Code:
    DeviceName = Device.name(hs)
    Dim DN() As String = DeviceName.Split()
    DeviceName = DN(0)
    Or, in its shortest form:

    Code:
    DeviceName = Device.name(hs)
    DeviceName = Split(DeviceName)(0)
    Jon

    Comment


      #3
      Originally posted by jon00 View Post
      Code:
      DeviceName = Device.name(hs)
      Dim DN() As String = DeviceName.Split()
      DeviceName = DN(0)
      Or, in its shortest form:

      Code:
      DeviceName = Device.name(hs)
      DeviceName = Split(DeviceName)(0)
      Ahhh, thanks Jon.
      I had the Split(DeviceName) part but was trying to incorporate a delimiter argument for free space.
      I didn't take into account the array.
      This is good because it means it will still work on single word names too without error or extra code.

      Thanks Jon.

      Comment

      Working...
      X