Jump to content
Sign in to follow this  
Chimaera

[Sorted] Confused with IniWrite

Recommended Posts

Chimaera

Ok i sorted a few check against websites and wrote the numbers to console then i made it make an ini file to hold the current version info

Code

$AVG_key = ConsoleWrite(_GetUpdates("AVG Free Edition") & @CRLF)
IniWrite( @ScriptDir & "\latest_version.ini", "AVG Free Edition", "Version ",$AVG_key)
$SSD_key = ConsoleWrite(_GetUpdates("Spybot Search & Destroy") & @CRLF)
IniWrite( @ScriptDir & "\latest_version.ini", "Spybot Search & Destroy", "Version ",$SSD_key)
$MAM_key = ConsoleWrite(_GetUpdates("Malwarebytes Anti-Malware") & @CRLF)
IniWrite( @ScriptDir & "\latest_version.ini", "Malwarebytes Anti-Malware", "Version ",$MAM_key)
$CC_key = ConsoleWrite(_GetUpdates("Ccleaner") & @CRLF)
IniWrite( @ScriptDir & "\latest_version.ini", "Ccleaner", "Version ",$CC_key)
$DF_key = ConsoleWrite(_GetUpdates("Defraggler") & @CRLF)
IniWrite( @ScriptDir & "\latest_version.ini", "Defraggler", "Version ",$DF_key)


Func _GetUpdates($sID) ; by GEOSoft (If I remember)
    Local $aReturn, $bRead, $sRead
    $bRead = InetRead("http://www.filehippo.com/search?q=" & $sID)
    $sRead = BinaryToString($bRead)

    $aReturn = StringRegExp($sRead, "(?i)" & $sID & "\s?((?:\d{1,5})(?:\.\d{1,5}){1,4})", 1)
    If @error Then
        Return SetError(1, 0, "None - Error")
    EndIf
    Return $aReturn[0]
EndFunc   ;==>_GetUpdates

Consolwrite i get this

10.0.1392
2.0
1.51.1
3.09.1493
2.06.328

On the ini i get this

[AVG Free Edition]
Version=11
[Spybot Search & Destroy]
Version=5
[Malwarebytes Anti-Malware]
Version=8
[Ccleaner]
Version=11
[Defraggler]
Version=10

What the hell went wrong its only supposed to copy the file number across ??

And is there a way to have a space between each group in the ini?

Edited by Chimaera

Share this post


Link to post
Share on other sites
BrewManNH

ConsoleWrite's return value is defined like this:

Return Value

The amount of data written. If writing binary, the number of bytes written, if writing text, the number of characters written.

You got the number of characters it wrote to the console, not the return value of _GetUpdates

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
BrewManNH

Bummer guess ill have to look at text files then

Thx BrewManNH

No, you'd just have to recode the parts of the script that use the _GetUpdates function to return the value to the variables instead of using it in the ConsoleWrites. Like this

$AVG_key = _GetUpdates("AVG Free Edition")
ConsoleWrite($AVG_key & @CRLF)
IniWrite( @ScriptDir & "\latest_version.ini", "AVG Free Edition", "Version ",$AVG_key)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
JohnOne

Write your own _IniWrite() function.

Example:

Func _IniWrite($Filename,$Section,$Key,$Value)
    Local $blankline = 0
    IniReadSection($Filename,$Section)
    If @error Then $blankline = 1
    If $blankline Then FileWrite($Filename,@CRLF)
    IniWrite($Filename,$Section,$Key,$Value)
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
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
Sign in to follow this  

×