Jump to content

Problem for read ini file


Recommended Posts

  • Moderators

Thebarbarius,

Is the data you read in the correct ini format? If not, then IniRead will fail.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

3 minutes ago, Thebarbarius said:

I don't  have problem with local file.

Hmm, I'm getting an Error from InetRead :

Local $dData      = InetRead("https://www.mysitehelp.com/news.txt")
Local $iError     = @error
Local $iBytesRead = @extended
ConsoleWrite("Error     = " & $iError & @CRLF & _
             "BytesRead = " & $iBytesRead & @CRLF )

Local $sData = BinaryToString($dData)
ConsoleWrite($sData & @CRLF)

 

Edited by Musashi
typo

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Think he's replaced the original URL because the website isn't accessible for me.

#include <Array.au3>

Local $dData = InetRead('https://www.mysitehelp.com/news.txt')
If @error Then ConsoleWrite('Error: InetRead - ' & @error & @CRLF)
Local $sData = BinaryToString($dData)
Local $aArray = IniReadSection($sData, 'NEWS')
If @error Then ConsoleWrite('Error: IniReadSection - ' & @error & @CRLF)
_ArrayDisplay($aArray)

What output do you get from the above @Thebarbarius?

Link to comment
Share on other sites

I think IniReadSection only accepts a File Name, not text.

Quote

IniReadSection ( "filename", "section" )

Maybe try writing the text to an INI file first?

#include <Array.au3>
#include <File.au3>

Local $dData = InetRead('https://www.mysitehelp.com/news.txt')
If @error Then ConsoleWrite('Error: InetRead - ' & @error & @CRLF)
Local $sData = BinaryToString($dData)
Local $hFile = FileOpen(@ScriptDir & '\Output.ini', 2)
FileWrite($hFile, $sData)
FileClose($hFile)
Local $aArray = IniReadSection(@ScriptDir & '\Output.ini', 'NEWS')
If @error Then ConsoleWrite('Error: IniReadSection - ' & @error & @CRLF)
_ArrayDisplay($aArray)

 

Edited by Luke94
Link to comment
Share on other sites

5 minutes ago, Luke94 said:

What output do you get from the above

Error: InetRead - 13
Error: IniReadSection - 1

The error arises, as in my example, already at InetRead. -1 at IniReadSection is a subsequent error.

@Thebarbarius : Please run the script from @Luke94 and post the output from the SciTE console.

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

I have make this :
 

Local $dData = InetRead('https://www.mywebsite.com/news.txt')
    If @error Then ConsoleWrite('Error: InetRead - ' & @error & @CRLF)
    Local $sData = BinaryToString($dData)
    Local $hFile = FileOpen(@ScriptDir & '\Output.ini', 2)
    FileWrite($hFile, $sData)
    FileClose($hFile)
    Local $aArray = IniReadSection(@ScriptDir & '\Output.ini', 'NEWS')
    If @error Then ConsoleWrite('Error: IniReadSection - ' & @error & @CRLF)
    
        For $i = 1 To $aArray[0][0]
        $previousJournalNews = GUICtrlRead($journalNews)

            GUICtrlSetData($journalNews, $aArray[$i][1] & @CRLF)

    Next

And i have this result :
image.png.326c83d56c9f84965e8e77ae21b7298d.png

Why i don't have all news in my GUI ?
 

Quote

[NEWS]
1=Welcomme
2=BLAVLA

 

Link to comment
Share on other sites

1 hour ago, Thebarbarius said:

Hello i have this :

Local $dData = InetRead("https://www.mysitehelp.com/news.txt")

Local $aArray = IniReadSection($dData, "NEWS")

MsgBox(0, "test", $aArray)

Can you help with external file ?

My return value for MsgBox is 1 and not array.

Help me please THX

The reason you are not getting the return you are probably hoping for, is you are not specifying what part of the $aArray, so it just appears blank or you get an error return value.

For instance, if you use the following, you will get the number 2, which is how many entries for NEWS.

MsgBox(0, "test", $aArray[0][0])

Also try something like

MsgBox(0, "test", $aArray[0][1])

or

MsgBox(0, "test", $aArray[1][0])

Then investigate the Help file to get an explanation for the IniReadSection command.

 

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Func _Example2()


    Local $dData = InetRead('https://www.mywebsite.com/news.txt')
    If @error Then ConsoleWrite('Error: InetRead - ' & @error & @CRLF)
    Local $sData = BinaryToString($dData)
    Local $hFile = FileOpen(@ScriptDir & '\Output.ini', 2)
    FileWrite($hFile, $sData)
    FileClose($hFile)
    Local $aArray = IniReadSection(@ScriptDir & '\Output.ini', 'NEWS')
    If @error Then ConsoleWrite('Error: IniReadSection - ' & @error & @CRLF)
    
        For $i = 0 To $aArray[0][0]
            $previousJournalNews = GUICtrlRead($journalNews)

            GUICtrlSetData($journalNews, $aArray[$i][1] & @CRLF)
    Next

EndFunc


With this i don't know how to add all news in GUI
If u can help it's important

Link to comment
Share on other sites

  • Moderators

Thebarbarius, or should I call you YuChan?

Why have you opened a new account after having been banned previously?

M23

P.S. And just to be absolutely clear - this is the Mod team determining the legality of the thread, so everyone else please keep out.

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

All,

Read the PS above. The next one who posts before I clear the thread gets a holiday. 

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...