Sign in to follow this  
Followers 0
commenti

Problem with my tabbed gui.

5 posts in this topic

Hello!

I have a problem with my Gui which uses a filerequester. If I try to save the value I get from the filerequester in an .ini File it won´t save.

To test my problem you need a file called test.ini in the diretory which conains the script.

test.ini comes first:

[common]
testpath=c:\test.txt

and here is the AutoIt code.

#include <GUIConstants.au3>

$daten = IniRead("test.ini", "common", "testpath", "")

GUICreate("My GUI Test-Tab") ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 380, 200)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlSetState(-1, $GUI_SHOW)
GUICtrlCreateLabel( "Test", 10, 32, 380, 200, 0x1000)
GUICtrlSetBkColor(-1, 0xffffff)

$tab1 = GUICtrlCreateTabItem("tab1")
GUICtrlCreateLabel("Data", 20, 150, 40, 20)
$datapath = GUICtrlCreateInput($daten, 80, 150, 180, 20)
$datapathbutton = GUICtrlCreateButton("a", 60, 150, 20, 20)


GUICtrlCreateTabItem(""); end tabitem definition


GUISetState()

; Run the GUI until the dialog is closed
While 1
   $msg = GUIGetMsg()
   If $msg = $datapathbutton Then
      $datei = FileOpenDialog("Please choose a file.", "", "(*.*)")
      GUICtrlSetData($datapath, $datei)
   EndIf
   
   If $msg = $GUI_EVENT_CLOSE Then
      $datei = GUICtrlRead($datapath)
      MsgBox(0, "This should be written:", $datei)
      IniWrite("test.ini", "common", "testpath", $datei)
      ExitLoop
   EndIf
WEnd

If you run this script the following happens:

In tab1 you have an inputbox, if you write some text there and then close the gui the text is written to the .ini file. If you use the button in the left side, you get a filerequester where you can choose any file. If you chose a file now, the inputbox will be updatet with the path of the file you have chosen. If you now close the gui this path will not be written to .ini file. The message box before the writing of the INI shows the correct value that I wan´t to write to the .ini file. Thats not working and I don´t know why. I really can´t find the bug.

Any help anybody?

Greetings...

commenti.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello!

I have a problem with my Gui which uses a filerequester. If I try to save the value I get from the filerequester in an .ini File it won´t save.

To test my problem you need a file called test.ini in the diretory which conains the script.

test.ini comes first:

[common]
testpath=c:\test.txt

and here is the AutoIt code.

#include <GUIConstants.au3>

$daten = IniRead("test.ini", "common", "testpath", "")

GUICreate("My GUI Test-Tab"); will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 380, 200)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlSetState(-1, $GUI_SHOW)
GUICtrlCreateLabel( "Test", 10, 32, 380, 200, 0x1000)
GUICtrlSetBkColor(-1, 0xffffff)

$tab1 = GUICtrlCreateTabItem("tab1")
GUICtrlCreateLabel("Data", 20, 150, 40, 20)
$datapath = GUICtrlCreateInput($daten, 80, 150, 180, 20)
$datapathbutton = GUICtrlCreateButton("a", 60, 150, 20, 20)
GUICtrlCreateTabItem(""); end tabitem definition
GUISetState()

; Run the GUI until the dialog is closed
While 1
   $msg = GUIGetMsg()
   If $msg = $datapathbutton Then
      $datei = FileOpenDialog("Please choose a file.", "", "(*.*)")
      GUICtrlSetData($datapath, $datei)
   EndIf
   
   If $msg = $GUI_EVENT_CLOSE Then
      $datei = GUICtrlRead($datapath)
      MsgBox(0, "This should be written:", $datei)
      IniWrite("test.ini", "common", "testpath", $datei)
      ExitLoop
   EndIf
WEnd

If you run this script the following happens:

In tab1 you have an inputbox, if you write some text there and then close the gui the text is written to the .ini file. If you use the button in the left side, you get a filerequester where you can choose any file. If you chose a file now, the inputbox will be updatet with the path of the file you have chosen. If you now close the gui this path will not be written to .ini file. The message box before the writing of the INI  shows the correct value that  I wan´t to write to the .ini file. Thats not working and I don´t know why. I really can´t find the bug.

Any help anybody?

Greetings...

commenti.

<{POST_SNAPBACK}>

EDIT

prefix the path "C:\" or whateverpath u want it , to both the iniread and iniwrite and it will work fine.

Hardcopy

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

EDIT

prefix the path "C:\" or whateverpath u want it , to both the iniread and iniwrite and it will work fine.

Hardcopy

<{POST_SNAPBACK}>

Hello Hardcopy, thank you for the tip. It worked. I still don´t know why it has to be like that but, it works. What I wanted was that one:

IniWrite(@ScriptDir & "\test.ini", "common", "testpath", $datei)
         -------------

I´ll now prefix all my ini writes with that.

Thanx again.

Greetings Rockford

Share this post


Link to post
Share on other sites

Hello Hardcopy, thank you for the tip. It worked. I still don´t know why it  has to be like that but, it works. What I wanted was that one: 

IniWrite(@ScriptDir & "\test.ini", "common", "testpath", $datei)
         -------------

I´ll now prefix all my ini writes with that.

Thanx again.

Greetings Rockford

<{POST_SNAPBACK}>

Ah the @scriptDir was missing from your original posted code. I though you had missed declaring a path altogether.

I tested with @scriptDir prefixed in both iniread and iniwrite and it works ok to.

maybe you forgot to include in both places. Try it

Hardcopy


Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

Ah the @scriptDir was missing from your original posted code. I though you had missed declaring a path altogether.

I tested with @scriptDir prefixed in both iniread and iniwrite and it works ok to.

maybe you forgot to include in both places.  Try it

Hardcopy

<{POST_SNAPBACK}>

You are right, I did not declare a path. The @scriptDir was missing because I thought it was obsolte. Thats is because only the filerequester value was not saved but all other values were saved without using @scriptDir. This is what I don´t know why it is like that. However, with prefixing @scriptDir everything works fine.

Thanx again, grettings... commenti.

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  
Followers 0