Can anybody help me save some time ?

  • Thread starter Keith (Southend)G
  • Start date
K

Keith (Southend)G

Probably a big ask...

Quite a while ago I started looking at Visual Basics to see if I could write something that would save me much time each day in gathering synops. Unfortunately, I didn't get very far and circumstances with having to start my own business just took over. I don't know whether this is simple to someonewith a better understanding of these these things, but what I was trying to do is this:
From the following site each day, and I'll take 24th Novemeber as an example, I set the parameters as follows:

http://www.ogimet.com/synopsc.phtml.en

Select a Country or Territory, starting with 'Afghanistan' - format - text
Begin: 2012 - November - 23rd - 15 hours (Start)
End: 2012 - November - 24th - 14 hours (End)

I then repeat this for about 50 different Countries, which takes me about 10 minutes to do. I then save this as text file and then merge them in with the usual hour synop files from Dupage or FSU etc...

If I had some stand alone interface where I could select any number of Countries, the date/time parameters and one click downloads them into one text file simutaneously, that would be a dream for me.

Any takers ?

Keith (Southend) (e-mail address removed)
http://www.southendweather.net
"Weather Home & Abroad"
 
A

Auric__

Keith said:
Probably a big ask...

Quite a while ago I started looking at Visual Basics to see if I could
write something that would save me much time each day in gathering
synops. Unfortunately, I didn't get very far and circumstances with
having to start my own business just took over. I don't know whether
this is simple to someone with a better understanding of these these
things, but what I was trying to do is this: From the following site
each day, and I'll take 24th Novemeber as an example, I set the
parameters as follows:

http://www.ogimet.com/synopsc.phtml.en

Select a Country or Territory, starting with 'Afghanistan' - format -
text Begin: 2012 - November - 23rd - 15 hours (Start)
End: 2012 - November - 24th - 14 hours (End)

I then repeat this for about 50 different Countries, which takes me
about 10 minutes to do. I then save this as text file and then merge
them in with the usual hour synop files from Dupage or FSU etc...

If I had some stand alone interface where I could select any number of
Countries, the date/time parameters and one click downloads them into
one text file simutaneously, that would be a dream for me.

Any takers ?

Not really necessary to do this in VB. I can write a batch file to do this
for you -- trivially easy to write (I already have it mostly done), almost as
easy to modify if needed, and no compiling needed -- but I need a bit more
info:

- What version of Windows? (Yes, it matters.)
- Do you always use the same type, and if so, what type?
- Ditto sort order.
- Ditto nil reports.
 
K

Keith (Southend)G

Keith (Southend)G wrote:



















Not really necessary to do this in VB. I can write a batch file to do this

for you -- trivially easy to write (I already have it mostly done), almost as

easy to modify if needed, and no compiling needed -- but I need a bit more

info:



- What version of Windows? (Yes, it matters.)

- Do you always use the same type, and if so, what type?

- Ditto sort order.

- Ditto nil reports.

Hello Auric,

Thank you for your reply.

1. Primariy, Windows 7 (Incl Windows 7 Starter on Netbook), although I sometime use it on XP. (Windows 7 would be the one I would choose, one PC is 64 bit)
2. I have this set to 'ALL', 'SM' or 'SI' I thought were different times, but just I just tried the 3 varisnts and couldn't see any difference in the end result ?
3. 'Newest the first' I have it set to, but doesn't really matter.
4. 'Nil reports included' I have it set to, but again doesn't really matter.

Many thanks for you interest and help.

Keith (Southend, UK)
 
K

Keith (Southend)G

Keith (Southend)G wrote:



















Not really necessary to do this in VB. I can write a batch file to do this

for you -- trivially easy to write (I already have it mostly done), almost as

easy to modify if needed, and no compiling needed -- but I need a bit more

info:



- What version of Windows? (Yes, it matters.)

- Do you always use the same type, and if so, what type?

- Ditto sort order.

- Ditto nil reports.

Not sure if this is relavant, but the text file I save with this data is always called "ogimet.txt".

Keith (Southend)
 
A

Auric__

Keith said:
Not sure if this is relavant, but the text file I save with this data is
always called "ogimet.txt".

Do you add the new data to the existing text file, or do you replace it?

(FYI, I switched from a batch file to FreeBASIC. I'm a truly terrible VB.Net
programmer, and I hit a brick wall in the batch. Doing it in FreeBASIC will
let me give you a single program to compile, instead of "do this and then do
that and then do this third thing and then..." Results later today or
tomorrow, depending.)
 
K

Keith (Southend)G

Keith (Southend)G wrote:







Do you add the new data to the existing text file, or do you replace it?



(FYI, I switched from a batch file to FreeBASIC. I'm a truly terrible VB.Net

programmer, and I hit a brick wall in the batch. Doing it in FreeBASIC will

let me give you a single program to compile, instead of "do this and thendo

that and then do this third thing and then..." Results later today or

tomorrow, depending.)

I replace it. This file is just a means to an end, if you know what I mean.

I have something else that sorts it, and then I add the sorted data, which is broken down into hourly files, into, the hourly file(s) I already have.

It probably sounds confusing, but basically, the data from this site contains extra locations that I can not get from anywhere else, which I add to the main files. It just takes me 10 minutes each day to put this 'ogimet.txt'file together and would like to be able to download the multiple hits straight into one file. Actually, the name of the file initially is irrelavent.

Many thanks

Keith (Southend)
 
A

Auric__

Keith said:
I replace it. This file is just a means to an end, if you know what I
mean.

I have something else that sorts it, and then I add the sorted data,
which is broken down into hourly files, into, the hourly file(s) I
already have.

It probably sounds confusing, but basically, the data from this site
contains extra locations that I can not get from anywhere else, which I
add to the main files. It just takes me 10 minutes each day to put this
'ogimet.txt' file together and would like to be able to download the
multiple hits straight into one file. Actually, the name of the file
initially is irrelavent.

As I said, this is FreeBASIC, not VB.net. Any attempt at using this in any
version of VB (.Net or otherwise) will give you all sorts of lovely errors.
FreeBASIC is available here:

http://www.freebasic.net/get

(The installer is convenient, but I just use the .7z archive.)

The program is at the end of this post. To compile it, type this at the
command prompt:

fbc ogimet.bas

To function properly, the program needs 2 text files:

- countries.txt
This is a list of the countries you want, 1 country per line, like so:
Afg
Como
Keny
You can use either the short code (from the ogimet.com page's source) or
the country's full name, or any part thereof that makes it unique (i.e.
if you give it "trinidad", it returns Trinidad and Tobago, but if you
give it "united" you'll get UK, US, and UAE).

- dates.txt
This is the start and end date/times for your reports; first line is the
start date and the second is the end. The format looks like this:
2012 01 01 01
2012 01 02 00
Somewhat obviously, it's year-month-day-hour. It doesn't matter what
character is between the fields, as long as they're not all jammed
together. (I used spaces; you may want to use dashes or slashes.)

The program outputs everything into ogimet.txt. Fyi, it can take a while;
your ten minutes might only get cut by a minute or two, depending on what
countries you download. (I told it to grab the above 24 hours for *all*
countries; it took about 14 minutes, and resulted in a 10mb file.)

(In case you're wondering why I switched from batch to FB, it turns out
that ogimet.com sends the text file wrapped in HMTL, with Unix line
endings. I already had a program written to chop text out of <pre> blocks;
it was pretty easy to add downloading and Unix-to-Windows to it.)

If you need any help with this, give a shout. (Stay in this thread so it
catches my attention.)

'-----begin ogimet.bas-----
#lang "fblite"

CONST CR$ = CHR$(13)
CONST LF$ = CHR$(10)
CONST CRLF$ = CR$ & LF$
CONST xFF$ = CHR$(&hFF)
CONST url1$ = "http://www.ogimet.com/display_synopsc.php?lang=en&estado="


SUB REPLACE (baseStr AS STRING, replaceThis AS STRING, withThis AS STRING)
DIM tmpStr1 AS STRING, tmpStr2 AS STRING, tmpLng1 AS LONG
DIM lenIn AS LONG

lenIn = LEN(replaceThis)
IF lenIn < 1 THEN EXIT SUB

tmpStr1 = baseStr

looper1:
tmpLng1 = INSTR(tmpStr1, replaceThis)
IF tmpLng1 THEN
tmpStr2 = tmpStr2 & LEFT$(tmpStr1, tmpLng1 - 1) & withThis
tmpStr1 = MID$(tmpStr1, tmpLng1 + lenIn)
GOTO looper1
ELSE
baseStr = tmpStr2 & tmpStr1
END IF
END SUB


DIM cmd AS STRING, inpStr AS STRING, tmpStr AS STRING, tmpLng AS LONG

DIM URLDownloadToFile AS FUNCTION (BYVAL pCaller AS LONG, _
BYVAL szURL AS zString PTR, _
BYVAL szFileName AS zString PTR, _
BYVAL dwReserved AS LONG, _
BYVAL lpfnCB AS LONG) AS LONG

DIM AS ANY PTR library = DyLibLoad("urlmon.dll")
URLDownloadToFile = DyLibSymbol(library, "URLDownloadToFileA")

OPEN "countries.txt" FOR INPUT AS 1
OPEN "ogimet.txt" FOR OUTPUT AS 2

OPEN "dates.txt" FOR INPUT AS 3
LINE INPUT #3, tmpstr
tmpstr = TRIM$(tmpstr)
yrst$ = LEFT$(tmpstr, 4)
most$ = MID$(tmpstr, 6, 2)
dyst$ = MID$(tmpstr, 9, 2)
hrst$ = RIGHT$(tmpstr, 2)
LINE INPUT #3, tmpstr
tmpstr = TRIM$(tmpstr)
yren$ = LEFT$(tmpstr, 4)
moen$ = MID$(tmpstr, 6, 2)
dyen$ = MID$(tmpstr, 9, 2)
hren$ = RIGHT$(tmpstr, 2)
CLOSE 3

WHILE NOT EOF(1)
LINE INPUT #1, what$
what$ = TRIM$(what$)
IF LEN(what$) THEN
tmpLng = URLDownloadToFile(0, url1 & TRIM$(what$) & _
"&tipo=ALL&ord=REV&nil=SI&fmt=TXT&ano=" & yrst$ & _
"&mes=" & most$ & "&day=" & dyst$ & "&hora=" & hrst$ & _
"&anof=" & yren$ & "&mesf=" & moen$ & "&dayf=" & dyen$ & _
"&horaf=" & hren$, CURDIR$ & "\" & TRIM$(what$), 0, 0)

IF 0 = tmpLng THEN
OPEN what$ FOR BINARY AS 4
inpStr = SPACE$(LOF(4))
GET #4, 1, inpStr
CLOSE 4

REPLACE inpStr, CRLF$, xFF$
REPLACE inpStr, CR$, xFF$
REPLACE inpStr, LF$, xFF$
REPLACE inpStr, xFF$, CRLF$

tmpLng = INSTR(LCASE$(inpStr), "<pre>")
IF tmpLng THEN
inpStr = MID$(inpStr, tmpLng + 5)
ELSE
PRINT #2, inpStr;
GOTO noPre
END IF

tmpLng = INSTR(LCASE$(inpStr), "</pre>")
IF tmpLng THEN inpStr = LEFT$(inpStr, tmpLng - 1)

noPre:
PRINT #2, inpStr;
KILL what$
END IF
END IF
WEND

CLOSE

DyLibFree library
'-----end ogimet.bas-----
 
K

Keith (Southend)G

Thanks Auric,

A couple of things I want to check.

1. http://www.freebasic.net/get
(The installer is convenient, but I just use the .7z archive.)
I'm currently on a 64bit PC, is this a problem ? If it is, I'll only load it on my other 32 bit PC.

2. Unzipped the programme so it's created a folder :
C:\Users\User\Downloads\FreeBASIC-0.24.0-win32.zip\FreeBASIC-0.24.0-win32
Is this the folder I would need the two files 'countries.txt' & 'dates.txt'?

3. The code, do I just copy/paste it or should this be saved as something ?

Many thanks

Keith (Southend)

ps: Stuck at home due to snow!
 
K

Keith (Southend)G

Btw, this is the selection of Countries I grab data from, so shouldn't take as long...

Bulg
Croa
Cyp
Czec
Den
Dji
Ecua
El S
Fin
France
Germ
Green
Guat
Hung
Icel
Iraq
Iran
Irel
Isra
Ital
Kuwait
Liec
Luxe
Mace
Mald
Netherland
Norw
Oma
Pak
Pal
Pana
Phil
Pola
Port
Puer
Roma
Russ
Serb
Slova
Slove
Spa
Sri L
Swed
Swit
Thai
Turke
Tuva
United K
United S
 
K

Keith (Southend)G

Sorry about the string of posts, but they all probably tie together...

OK, on my 32bit Win XP PC I have extracted the:
FreeBASIC-0.24.0-win32.zip file into a folder, so it's all together.
Put the two files dates and countries into the same folder. When I click on fbc.exe a command window just flashes in and out, just wondered what I'm doing wrong?

Regards

Keith (Southend)
 
A

Auric__

Keith said:
A couple of things I want to check.

1. http://www.freebasic.net/get
(The installer is convenient, but I just use the .7z archive.)
I'm currently on a 64bit PC, is this a problem ? If it is, I'll only
load it on my other 32 bit PC.

64-bit Windows can run 32-bit programs just fine.
2. Unzipped the programme so it's created a folder :
C:\Users\User\Downloads\FreeBASIC-0.24.0-win32.zip\FreeBASIC-0.24.0-win32
Is this the folder I would need the two files 'countries.txt' &
'dates.txt'?

They need to be in the same folder as ogimet.exe.
3. The code, do I just copy/paste it or should this be saved as
something ?

Copy it and paste it into notepad. Save it as "ogimet.bas" ***WITH THE
QUOTES*** (in other words, it shouldn't be a text file -- you want
ogimet.bas, not ogimet.bas.txt). Put that into the FreeBASIC folder. More
instructions below.

------------------------------------------------------------------------
Btw, this is the selection of Countries I grab data from, so shouldn't
take as long...

Those are what needs to go in countries.txt.

------------------------------------------------------------------------
Sorry about the string of posts, but they all probably tie together...

OK, on my 32bit Win XP PC I have extracted the:
FreeBASIC-0.24.0-win32.zip file into a folder, so it's all together.
Put the two files dates and countries into the same folder. When I click
on fbc.exe a command window just flashes in and out, just wondered what
I'm doing wrong?

fbc isn't a graphical program, it runs from the command line. Open a
command prompt (in XP: Start -> Run... -> cmd -> enter; in Win7: Start ->
cmd -> enter.) and type this:

cd /d C:\Users\User\Downloads\FreeBASIC-0.24.0-win32.zip\FreeBASIC-
0.24.0-win32
fbc ogimet.bas

(Note that the "cd" line is long and wraps. Don't press enter until *after*
you've hit that last "-win32".)

That should create ogimet.exe. The two text files go in the same directory
as ogimet.exe; what folder they all are in doesn't matter as long as
they're together.

(Once you have ogimet.exe, you can remove FreeBASIC if you want... but
*test* ogimet.exe first.)
 
K

Keith (Southend)G

Keith (Southend)G wrote:









64-bit Windows can run 32-bit programs just fine.







They need to be in the same folder as ogimet.exe.







Copy it and paste it into notepad. Save it as "ogimet.bas" ***WITH THE

QUOTES*** (in other words, it shouldn't be a text file -- you want

ogimet.bas, not ogimet.bas.txt). Put that into the FreeBASIC folder. More

instructions below.



------------------------------------------------------------------------







Those are what needs to go in countries.txt.



------------------------------------------------------------------------










fbc isn't a graphical program, it runs from the command line. Open a

command prompt (in XP: Start -> Run... -> cmd -> enter; in Win7: Start ->

cmd -> enter.) and type this:



cd /d C:\Users\User\Downloads\FreeBASIC-0.24.0-win32.zip\FreeBASIC-

0.24.0-win32

fbc ogimet.bas



(Note that the "cd" line is long and wraps. Don't press enter until *after*

you've hit that last "-win32".)



That should create ogimet.exe. The two text files go in the same directory

as ogimet.exe; what folder they all are in doesn't matter as long as

they're together.



(Once you have ogimet.exe, you can remove FreeBASIC if you want... but

*test* ogimet.exe first.)


It worked :)

This is on my 64Bit Win 7 PC, really quick, about 20 seconds. I will set it up on my Netbook later.

I assume I have to install FreeBASIC on each PC I used, or can you just copy the files in that directory ?

Will keep you posted.

Very many thanks.

Keith (Southend)
 
K

Keith (Southend)G

Working on my NetBook now.
Had to move to another folder as I couldn't find the original folder from the command prompt, maybe something to do with .zip in the path ? Not such a fast processor, but still much quicker and of course you just let it run.

This helps me no end, especially when I take my Netbook on holiday, I can grab the data quite painlessly

Again, many thanks for bearing with me with this Auric, this has made things much easier for me now.

Best regards

Keith (Southend)
 
A

Auric__

Keith said:
It worked :)

This is on my 64Bit Win 7 PC, really quick, about 20 seconds. I will set
it up on my Netbook later.

I assume I have to install FreeBASIC on each PC I used, or can you just
copy the files in that directory ?

No need to copy FB. The only purpose it served was to compile ogimet.bas.
Once that's done, you're safe to remove FB from your system if you want;
certainly don't *need* to put it on the other computers unless you want to.
There's no runtime needed by FB programs, aside from a few standard Windows
libraries.

-----------------------------------------------------------------------------
Working on my NetBook now.
Had to move to another folder as I couldn't find the original folder
from the command prompt, maybe something to do with .zip in the path ?
Not such a fast processor, but still much quicker and of course you just
let it run.

If you were trying to run it directly from the zip file, then that's the
problem right there.
This helps me no end, especially when I take my Netbook on holiday, I
can grab the data quite painlessly

....as long as you have to proper files with you to begin with, I suppose.
Again, many thanks for bearing with me with this Auric, this has made
things much easier for me now.

No problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top