Jump to content

IniWrite gets ignored


 Share

Recommended Posts

Hello.

Here's the code.

$pathToConfig = IniRead("settings.ini", "General", "PathToConfig", "")
If  Not FileExists($pathToConfig) Then
    TrayTip("Script", "Please point me to config file.", 5)
    $newPath = FileOpenDialog("Script", @ScriptDir, "Config files (*.cfg)", 1)
    IniWrite("settings.ini", "General", "PathToConfig", $newPath)
    $pathToConfig = $newPath
EndIf

So IniWrite with $newPath gets ignored for some reason. It returns 1, which means success, but still strange.

I tried using some random strings instead of $newPath, for example "test1235", but still no success.

But the most interesting thing is that IniWrite works when used before IniRead. That is, it gets updated both in NP++ and via the code.

Additional info:

  • I have 3 more IniReads above $pathToConfig line;
  • Sometimes the value just doesn't change in .ini file, and sometimes (1 case of like 10) it becomes blank (when used after IniRead).

Would appreciate any help.

Edited by Helixanon
Link to comment
Share on other sites

Oh wow wait. I actually didn't notice the "\" sign you've put. I typed it and for some reason it did, indeed, update the file.

So uhm, why was it needed to insert the scriptDir and put the backslash? Shouldn't it be working with non-absolute path?

Anyway, the issue is solved, and I thank you.

Link to comment
Share on other sites

There is nothing apparent which should cause that code to not work, especially if it returns 1, and is why I suspect there is more code at play since the code supplied does not test it.

But perhaps the help file is wrong and it does require full path.

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

Monkey's are, like, natures humans.

Link to comment
Share on other sites

The post #1 code worked here as is.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Moderators

Helixanon,

I think the reason behind the problem lies in this section of the Help file (my bold):

Quote

The working directory is set to @ScriptDir at script start and this path can be altered during the running of the script by calling FileChangeDir. But note that the current working directory can be also be changed automatically by some functions - e.g. FileOpen/SaveDialog on a successful return,

So after a successful selection of the new path, the working directory is reset to the selected folder and so you need to specify the full path of the ini file - or reset the working folder to @ScriptDir using FileChangeDir.

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

Ah yes, thanks Melba, you refresh my memory... I remember now this behaviour with FileOpenDialog and FileSaveDialog.
I had the answer but not the explaination...

Edited by jguinch
Link to comment
Share on other sites

Ooooh, that's interesting. So as summary, after FileOpenDialog it tried to look for .ini file in the folder which was returned by FileOpenDialog? Funny stuff. Right, should've mentioned that the .ini file was in a same folder but I thought it was obvious :)

Thank you.

Edited by Helixanon
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...