Announcement

Collapse
No announcement yet.

vb script to read/parse file for Raspberry Pi/HS3

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

    #16
    Success!

    Holy cow, I got it working!

    I had to go a different route, but it works! This is a heavily modified version of Rob Mason's example. I'm sure there are ways to make what I've done much more efficient, but I'm happy with it for now! I never did figure out why the other method wouldn't work, so Bob, I'm hoping this has helped you in some way at least.


    Code:
    Imports System.IO 
    
    ''Heavily modified from Rob Mason's ZeeTemperature.vb - Thanks Rob!
    ''ZeeTemperature.vb - Rob Mason - 10/23/2013 - Free to use/modify. 
    
    Sub Main(parm as object) 
    
       dim sr as StreamReader 
       dim wxdata as String 
       dim lin as String 
       dim SplitStr() As String
       
       Try 
    	sr = new StreamReader("/mnt/wxlogs/scriptlog.txt") 'directed to my weather server
    
    	wxdata = sr.ReadToEnd	'read the entire file (it's only two lines)
    	lin = Split(wxdata, VBCrLf)(1) 'read the second line of text
    
    	SplitStr = Split(lin, ",") 'grab each value between the commas
    
    	hs.writelog("Year", SplitStr(0)) '1st value
    	hs.writelog("Month", SplitStr(1)) '2nd value
    	hs.writelog("Day", SplitStr(2)) '3rd value
    	hs.writelog("Hour", SplitStr(3)) '4th value
    	hs.writelog("Minute", SplitStr(4)) '5th value
    	hs.writelog("Wind", SplitStr(5)) '6th value
    	hs.writelog("Gust", SplitStr(6)) '7th value
    	'etc 
    	'these values can now be assigned to virtual devices
    
       Catch ex as Exception 
          hs.WriteLog("WD",ex.Message) 
       Finally 
          if(not sr is Nothing) then sr.close() 
       End Try 
    End Sub

    Comment

    Working...
    X