Jump to content

read a text file and extract information


Recommended Posts

1 hour ago, Shark007 said:

This is some damn nice code too

yes but try with the wrong URL and watch it crash :( 

#include <Constants.au3>
#include <InetConstants.au3>
Exit MsgBox($MB_SYSTEMMODAL, "", Example8("https://shark007.net/build.lo_g"))
Func Example8($sURL)
    Local $s = BinaryToString(InetRead($sURL, $INET_FORCERELOAD))
    If Not StringLen($s) Then Return SetError(1, 1, "no data")
    Local $a = StringRegExp($s, "Version: ([^\v]*)", 1)
    If @error Then Return SetError(@error, 2, "not found")
    Return StringReplace(StringLeft($a[0], StringInStr($a[0], "-", 0, -1)-1), "-", ".")
EndFunc   ;==>Example

Checking each step has it's merits.
Coding to one's level of understanding is better for debugging than magical stuff. ( Clarification: I'd love to understand RegExp but If I don't, I'll have to dumb it down a bit )

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

2 hours ago, argumentum said:

I love these one-liners. They are streamlined. They look like, wow 😲
Unfortunately there is no room to add an "If @error Then" 🧐

This is exactly why after test these, I went back to using the one in post 6. The one from post 6 does not crash.

Edited by Shark007
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...