kengr: (Brain)
kengr ([personal profile] kengr) wrote2004-12-04 06:02 am

Programming help request

Ok, I've got my nifty-neato weather station running. But the program for putting the data on the web insists on doing so by creating a *graphic*. This is seriously stupid. Especially given that it's working from a *text* data file.

The file seems to be formatted like a Windows INI file. I know there are routines out there for parsing such files, so I'd rather not re-invent the wheel.



What I need are a set of functions for extracting info from such files. Ones that can be plugged into a BASIC that's not too far from QuickBasic or TurboBasic. Or into Turbo Pascal 7. Yes, I'm behind the times, deal.

My goal is to generate and upload an HTML file from the text file. I can do the automatic FTP easily, just takes a simple 4NT script.

It's parsing the file that is going to be a pain. I'd rather have generalized code that I could re-use later than write something that's specific to the format of this data file.

Here's a sample of the file:


[header]
programm_name = "heavy weather"
programm_version = "Ver. 2.0 beta release"
file_name = "currdat.lst"
file_format_version = "ver. 1.0"

[time]
start = 3311155037
start_date_string = "Sat Dec 04 05:17:17 2004"
last_actualisation = 3311157092
last_actualisation_date_string = "Sat Dec 04 05:51:32 2004"
next_actualisation = 3311157152
next_actualisation_date_string = "Sat Dec 04 05:52:32 2004"

[weather_picture]
comment = "-1=not valid, 0=rain, 1=cloud, 2=sun"
number = 0

[weather_tendency]
comment_1 = "-1=not valid, 0=no change of air pressure"
comment_2 = " 1=air pressure rising, 2=air pressure falling"
number = 2

[indoor_temperature]
deg_C = "22.0"
deg_F = "71.6"

[outdoor_temperature]
deg_C = "5.6"
deg_F = "42.0"

[indoor_humidity]
percent = "24"

[outdoor_humidity]
percent = "76"

[dewpoint]
deg_C = "1.7"
deg_F = "35.2"

[windchill]
deg_C = "---"
deg_F = "---"

[wind_speed]
mps = "---"
kmh = "---"
mph = "---"
knt = "---"
bft = "--"

[wind_direction]
deg = "---.-"
name = "---"

[rain_total]
mm = "0.0"
inch = "0.00"

[rain_24h]
mm = "0.0"
inch = "0.00"

[rain_1h]
mm = "0.0"
inch = "0.00"

[pressure_absolute]
hpa = "1000.1"
inHg = "29.53"

[pressure_relative]
hpa = "1009.1"
inHg = "29.79"

[storm_alarm]
comment = "-1=not valid, 0=storm alarm not activ, 1=storm alarm activ"
number = 1


[identity profile] freetrav.livejournal.com 2004-12-04 08:11 am (UTC)(link)
The fact that you're using a '4NT script' suggests that the machine you're using is either Windows NT, Windows 2000, or Windows XP. If it's 2000 or XP, you also have something called the Windows Scripting Host, which has both a console version (cscript) and a GUI version (wscript). Scripts for those are written in either jscript (which is a MS-ized javascript) or VBScript (which is a cut-down Visual Basic). I know there's a way to call the Windows API and use the INI-manipulation routines from the two scripting languages, so you might want to look into rewriting into VBScript. Other than that, I'd have to reinvent the wheel myself.

[identity profile] freetrav.livejournal.com 2004-12-05 08:29 am (UTC)(link)
Oh, I'm familiar with the JPSoft command prompt replacements (was on the beta team for a while); I just didn't realize that 4NT would run on Win 9x - those were designed for the WinNT-stream products, hence my comments above. If you're running on Win98 or WinME, I believe you can get the Windows Scripting Host for those as well, as a freebie d/l from MS. I don't think it'll work on Win95, though.

Back to your original question, though - I poked 'Pascal library read ini' into Google, and one of the pages it came back with was http://www.bookcase.com/library/software/msdos.devel.apps.turbo-pascal.html. That page contains a LONG listing of libraries and utilities for Pascal, mostly the Borland series, and one of the items listed was EZ-INI1S, with a link to ftp://ftp.simtel.net/pub/simtelnet/msdos/turbopas/ez_ini1s.zip - so have fun!