Page 1 of 1 1
Topic Options
#13462 - 2001-10-23 06:51 PM Read information from file to messagebox
Faceman Offline
Fresh Scripter

Registered: 2001-10-18
Posts: 14
Loc: The Netherlands
I want to read the contents of a file (info.txt) to a messagebox on the screen. The file contains a couple of lines like:

last changes: October 23rd
fixed: update.exe, update.txt
changed by: mmo/ict

The file can also contain more lines than the three I mentioned above.

I want my script to read the lines from info.txt and display all the lines in one messagebox. The readline(x) statement has to continue untill there is no more input from the info.txt file. If the file info.txt contains 3 lines, it should stop at the 4th.

I already created something like this


code:
 
IF Open(2, "info.txt") = 0
$r= readline(2)
While instr("$r","stop!") = 0
$r=$r + ReadLine(2) + chr(13) + chr(10)
Loop
$Selection = MessageBox("There is a update available

update info:

$r
Continue with the update?", "Update", 0)
Endif
Close (2)


A few problems remain...

There has to be a line containing 'stop!' in the file to stop the input from the info.txt file. This is a very simple flag and I think this can be done a lot nicer.

All the lines read from info.txt have to be displayed below each other in the messagebox. What's the correct CHR code to do so? chr(13)+chr(10) doesn't seem to do the trick.

Anyone got a better solution?

Mac

Top
#13463 - 2001-10-23 07:36 PM Re: Read information from file to messagebox
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Face,

Here's sort of a step-by-step way of doing it. Plus, it will read the info file until EOF is found ...

code:

if open(2, "info.txt") = 0


$info = readline(2) + chr(13)


while @error = 0
$info = $info + ReadLine(2) + chr(13)
loop


$message = "There is a update available" + chr(13) + chr(13)
+ "Update Info:" + chr(13) + chr(13) + $info
+ "Continue with the update?"


$answer = messagebox($message,"Update",0)


$q=close(2)


endif


-Shawn

Top
#13464 - 2001-10-23 07:56 PM Re: Read information from file to messagebox
Faceman Offline
Fresh Scripter

Registered: 2001-10-18
Posts: 14
Loc: The Netherlands
Much obliged... Thanks Shawn! Works like a charm. You wouldn't happen to know a way to check fot the presence of a dial-up connection in Windows 2000, would you?

Mac

[ 23 October 2001: Message edited by: Faceman ]

Top
#13465 - 2001-10-23 08:19 PM Re: Read information from file to messagebox
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Faceman ... (wasn't that the 'nickname' of one of those A-team guys ???)

I'd bet the house Shawn is knowing of a way to check for a ras connection ....

In the mean time : try playing with @ras ...

should work for you like :

code:

if @ras
;Yes, there is an active ras connection !
endif

J.

_________________________



Top
#13466 - 2001-10-23 08:25 PM Re: Read information from file to messagebox
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Faceman ... (wasn't that the 'nickname' of one of those A-team guys ???)
I'd bet the house Jochen is knowing of a way to check for a ras connection ....

In the mean time : try playing with @ras ...

should work for you like :


code:
--------------------------------------------------------------------------------

if @ras ;Yes, there is an active ras connection !endif

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

S.

opps - Jochen beat me to it !


Top
#13467 - 2001-10-23 08:30 PM Re: Read information from file to messagebox
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Dear

thanx pal !
That's what I call a reply !!!

hmmm ... now I know why they call Opera the fastest browser on earth ....


[FYI=You still @ work ??? waiting still for build 4 , you know ?]

[ 23 October 2001: Message edited by: jpols ]

_________________________



Top
#13468 - 2001-10-23 08:45 PM Re: Read information from file to messagebox
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Yap - I'm at work (working on build 4) - shame on me !!! It's just after lunch time here so I guess that's allowed eh ?

Your design recommendations are working out beautifully by the way - way better than the old strategy I was using. Much more intuitive and natural ... are you at work or at home ... when can we ICQ next ?

-Shawn

Top
#13469 - 2001-10-23 08:46 PM Re: Read information from file to messagebox
Faceman Offline
Fresh Scripter

Registered: 2001-10-18
Posts: 14
Loc: The Netherlands
Pfew... @RAS Probably a new command. I really should check those KiXtart manuals for new commands someday. Thanks again guys.

Mac

Top
#13470 - 2001-10-23 08:51 PM Re: Read information from file to messagebox
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Face : try out the chm files provided here and @ scriptlogic.com !!! Helped me a LOT !

Shawn : @work for another 10 mins ... icq possible this week between 5:00 am and 2:00 (3:00 pm) pm YOUR time

J.

[ 23 October 2001: Message edited by: jpols ]

_________________________



Top
#13471 - 2001-10-23 08:57 PM Re: Read information from file to messagebox
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
J

ok - try to catch you early one morn ...

Face:

You have get one of the .CHM help files ... ScriptLogic's is particularily good and up-to-date ... very, very handy to use !!!

-Shawn

Top
#13472 - 2001-10-23 09:08 PM Re: Read information from file to messagebox
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
10-4 Shawn ... [over and out ]

will try to catch you on icq .... damn timezones

Face: @ras is actually a macro, but ... who cares !!!

Hope to see you here from time to time !!!

Jochen

_________________________



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1336 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.06 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org