Jump to content

IniReadSection not finding Ini file or section... Both exist


Recommended Posts

Ok, there may be something totally obvious I'm overlooking here, but this function isn't working, and I'm not sure what's going on... Does anyone see any problems with it?

loadBookmarks()

Func loadBookmarks($section = "Roots")
    Local $i
    Local $temp = IniReadSection("res\bookmarks.ini", $section)
    If not IsArray($temp) Then MsgBox(0, "Error!", "Could not find file!")
    For $i = 1 to $temp[0][0]
        If $temp[$i][1] == "folder" Then
            MsgBox(0, "", "Found folder: " & $temp[$i][0])
            loadBookmarks($temp[$i][0])
        Else
            MsgBox(0, "", $temp[$i][0] & " exists under " & $section)
        EndIf
    Next
EndFunc
;C:\Users\magician13134\Desktop\msi\software\Vanilla Browser\mockup\

[Roots]
Tech=folder
Random=folder
[Tech]
Digg=http://www.digg.com/
Google 42 - The Answer to Everything=http://www.google42.com/
Magic Soft Inc.=http://www.magicsofitnc.com/
[Random]
eBay=http://www.ebay.com/
Ladyada=http://www.ladyada.net/
Search Engines=folder
New Grounds=http://www.newgrounds.com/
[Search Engines]
Yahoo=http://www.yahoo.com/
Excite=http://www.excite.com/
Google=folder
[Google]
Web=http://www.google.com/
Images=http://images.google.com/
Video=http://video.google.com/
;C:\Users\magician13134\Desktop\msi\software\Vanilla Browser\mockup\res

Anything else I'm overlooking?

Thanks

Link to comment
Share on other sites

This worked for me....

Dim $File = @ScriptDir & "\Times.ini"
loadBookmarks()

Func loadBookmarks($section = "Roots")
    Local $i
    Local $temp = IniReadSection($File, $section)
    If not IsArray($temp) Then MsgBox(0, "Error!", "Could not find file!")
    For $i = 1 to $temp[0][0]
        If $temp[$i][1] == "folder" Then
            MsgBox(0, "", "Found folder: " & $temp[$i][0])
            loadBookmarks($temp[$i][0])
        Else
            MsgBox(0, "", $temp[$i][0] & " exists under " & $section)
        EndIf
    Next
EndFunc

I am guessing its your "file location" thats the prob

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Huh, still doing what it did before. I'm really puzzled!

Although, I added this line of code:

If FileExists($File) Then MsgBox(0, "", "File exists...")oÝ÷ Ø   ݶ­2È£!£.¥8^uçm+¡×ºÚ"µÍÙÐÞ
    ][ÝÉ][ÝËÐ^QÜ^J[TXYÙXÝ[Û[YÊ    ÌÍÑ[JJJ
and it just shows 0

That makes me think my Ini file is wrong... But what you see up there is what I have... Isn't that right?

Edited by magician13134
Link to comment
Share on other sites

Does anyone see any problems with it?

The only problem that i can predict here, is with relative path (res\bookmarks.ini)... use full path, or set working dir to script dir:

loadBookmarks()

Func loadBookmarks($section = "Roots")
    Local $sOld_WorkDir = @WorkingDir
    FileChangeDir(@ScriptDir)
    Local $temp = IniReadSection("res\bookmarks.ini", $section)
    
    If not IsArray($temp) Then MsgBox(0, "Error!", "Could not find file!")
    
    For $i = 1 to $temp[0][0]
        If $temp[$i][1] == "folder" Then
            MsgBox(0, "", "Found folder: " & $temp[$i][0])
            loadBookmarks($temp[$i][0])
        Else
            MsgBox(0, "", $temp[$i][0] & " exists under " & $section)
        EndIf
    Next
    
    FileChangeDir($sOld_WorkDir)
EndFunc
Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Huh, still doing what it did before. I'm really puzzled!

Although, I added this line of code:

If FileExists($File) Then MsgBox(0, "", "File exists...")oÝ÷ Ø   ݶ­2È£!£.¥8^uçm+¡×ºÚ"µÍÙÐÞ
    ][ÝÉ][ÝËÐ^QÜ^J[TXYÙXÝ[Û[YÊ    ÌÍÑ[JJJ
and it just shows 0

That makes me think my Ini file is wrong... But what you see up there is what I have... Isn't that right?

IT is possible the problem lies in the FAT, not the script. Try recreating the INI.

If you cannot isolate the problem, try going back to basics, then building from there.

Cheers,

Hypoz

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Link to comment
Share on other sites

Thats what I thought/said too!

8)

Oops, sorry, i just read quickly the first and the last posts :)

magician13134

Maby the problem is in the path itself, the @ScriptDir inlude any non-ANSI characters? :)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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