Jump to content

iniwrite & GUICtrlCreateEdit


Recommended Posts

Hello Quicksilver,

thank you for your help, but it doesn't work :-(

Must I change the codelines to read the ini-file?

#Region Einlesen der Ini Datei --> informationen.ini & logbuch.ini
$file39 = IniRead(@ScriptDir & "\ini-Dateien\informationen.ini", 'Informationen', 'Informationen', '')
$file42 = IniRead(@ScriptDir & "\ini-Dateien\logbuch.ini", 'Logbuch', 'Logbuch', '')
#EndRegion Einlesen der Ini Datei --> informationen.ini & logbuch.ini
Link to comment
Share on other sites

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

@SlimShaddy:

Okay: I have a "Editfield" in that the user can leave informations. If the user make a return on the end of one line, the following lines are not been displayed after starting the program a second time. I save this informations by clicking on a save button. Now I hope you can help me...

Func Logbuch ()
$Fenster_Logbuch = GUICreate("", 640, 480 - 42, 0, 0, $WS_CHILD, -1, $Haupt_Fenster)
GUICtrlCreateGroup("Logbuch", 20, 20, 600, 400)
$input_logbuch = GUICtrlCreateEdit($file_logbuch, 35, 40, 570, 240)
GUICtrlSetData($input_logbuch, $file_logbuch)
EndFunc

Func logbuch_sichern()
If Not FileExists(@ScriptDir & "\ini-Dateien") Then
    DirCreate(@ScriptDir & "\ini-Dateien")
EndIf
    IniWrite(@ScriptDir & "\ini-Dateien\logbuch.ini", "Logbuch", "Logbuch", GUICtrlRead($input42))
EndFunc
Link to comment
Share on other sites

I understand now. I have done this before.

This is how you save the content.

$content = GUICtrlRead($input42) ;Save the content of the edit box
$Save2INI_line = StringReplace(StringStripCR($content), @LF, '\#nl')  ;Delete carriage returns and replace the line feeds with an unused string
IniWrite(@ScriptDir & "\ini-Dateien\logbuch.ini", "Logbuch", "Logbuch", $Save2INI_line)  ;Write the result to an INI file

This is how you restore it again:

$SavedINI_content = IniRead(@ScriptDir & "\ini-Dateien\logbuch.ini", "Logbuch", "Logbuch", "")
If $SavedINI_content <> "" Then
   If StringInStr($SavedINI_content, '\#nl') Then
      $SavedINI_content = StringReplace($SavedINI_content, '\#nl', @CRLF)
   EndIf
   GUICtrlSetData($input42, $SavedINI_content)
EndIf
Edited by SlimShady
Link to comment
Share on other sites

Hi,

thank for helping, but I have one more problem....

GUICtrlCreateGroup("Logbuch", -795, 180, 870, 290)
$input42 = GUICtrlCreateEdit($file42, 15, 25, 760, 240)
GUICtrlSetData($input42, $file42)
$ButtonSichern4 = GUICtrlCreateButton("Sichern", 780, 100)
GUICtrlSetOnEvent(-1, "Sichern4")

This is the code for the inputfield. How must I change the code, that your code works with inputfield code?

Link to comment
Share on other sites

$SavedINI_content = IniRead(@ScriptDir & "\ini-Dateien\logbuch.ini", "Logbuch", "Logbuch", "")
If $SavedINI_content <> "" Then
   If StringInStr($SavedINI_content, '\#nl') Then
      $SavedINI_content = StringReplace($SavedINI_content, '\#nl', @CRLF)
   EndIf
EndIf

GUICtrlCreateGroup("Logbuch", -795, 180, 870, 290)
$input42 = GUICtrlCreateEdit($SavedINI_content, 15, 25, 760, 240)
$ButtonSichern4 = GUICtrlCreateButton("Sichern", 780, 100)
GUICtrlSetOnEvent(-1, "Sichern4")

Link to comment
Share on other sites

@SlimShaddy:

Sorry that I am nerving you:

But I have a problem to implement the code in my project....

There were no input in the logbuch.ini

Here is the whole code as project to download, I hope you can help me a second time

Thank you for everything

Link to comment
Share on other sites

Now I have deactivated the Event Msg

#Region Logbuch
Func Logbuch ()
$Fenster_Logbuch = GUICreate("", 640, 480 - 42, 0, 0, $WS_CHILD, -1, $Haupt_Fenster)
GUICtrlCreateGroup("Logbuch", 20, 20, 600, 400)
$SavedINI_content_logbuch = IniRead(@ScriptDir & "\ini-Dateien\logbuch.ini", "Logbuch", "Logbuch", "")
If $SavedINI_content_logbuch <> "" Then
   If StringInStr($SavedINI_content_logbuch, '\#nl') Then
      $SavedINI_content_logbuch = StringReplace($SavedINI_content_logbuch, '\#nl', @CRLF)
   EndIf
EndIf
$input_logbuch = GUICtrlCreateEdit($SavedINI_content_logbuch, 35, 40, 570, 240)
$ButtonSichern4 = GUICtrlCreateButton("Sichern", 200, 400)
;GUICtrlSetOnEvent(-1, "logbuch_sichern")
EndFunc
#EndRegion Logbuch

But there must I set "$ButtonSichern4"?

Link to comment
Share on other sites

Okay, I have done it,

but there was one error message:

C:\Dokumente und Einstellungen\Marc\Desktop\Programmierung\xpr_install_menü.au3 (1295) : ==> Variable used without being declared.:

$content_logbuch = GUICtrlRead($input_logbuch) ;Save the content of the edit box

$content_logbuch = GUICtrlRead(^ ERROR

>Exit code: 0    Time: 1.163

And this is the code:

Func logbuch_sichern()
$content_logbuch = GUICtrlRead($input_logbuch);Save the content of the edit box
$Save2INI_line_logbuch = StringReplace(StringStripCR($content_logbuch), @LF, '\#nl') ;Delete carriage returns and replace the line feeds with an unused string
IniWrite(@ScriptDir & "\ini-Dateien\logbuch.ini", "Logbuch", "Logbuch", $Save2INI_line_logbuch) ;Write the result to an INI file
EndFunc
Link to comment
Share on other sites

Hello,

this is my code to save the logbuch with clicking on a button:

Case $msg = $ButtonSichern4
Then logbuch_sichern()

But it doesn'T work, there is an error message:

C:\Dokumente und Einstellungen\Marc\Desktop\Programmierung\xpr_install_menü.au3 (318) : ==> Invalid keyword at the start of this line.:

Link to comment
Share on other sites

select/case statements DONT USE "THEN" .... try this

Case $msg = $ButtonSichern4
   logbuch_sichern()

edit: try to actually READ what the erroe says to determine the problem... as with ur above problem before, you had a SYNTAX error where you must of mistakenly written the wrong variable, in other words a spelling mistake

edit2: after looking above at your other posts i have determined the problem, you are using that variable IN ANOTHER FUNCTION, you must declare the variable, at the top of your script put

Global $Input_LogBuch
Edited by burrup

qq

Link to comment
Share on other sites

@Burrup:

Okay thank you for your help, this works:

This is the result in the logbuch.ini file

[Logbuch]Logbuch=Zeile1\#nlZeile2\#nlZeile3\#nl

If i start the program a second time the following code doesn't functioned....

Func Logbuch()
$Fenster_Logbuch = GUICreate("", 640, 480 - 42, 0, 0, $WS_CHILD, -1, $Haupt_Fenster)
GUICtrlCreateGroup("Logbuch", 20, 20, 600, 400)

$SavedINI_content_logbuch = IniRead(@ScriptDir & "\ini-Dateien\logbuch.ini", "Logbuch", "Logbuch", "")
If $SavedINI_content_logbuch <> "" Then
   If StringInStr($SavedINI_content_logbuch, '\#nl') Then
      $SavedINI_content_logbuch = StringReplace($SavedINI_content_logbuch, '\#nl', @CRLF)
   EndIf
EndIf
$input_logbuch = GUICtrlCreateEdit($SavedINI_content_logbuch, 35, 40, 570, 240)
$ButtonSichern4 = GUICtrlCreateButton("Sichern", 200, 400)
EndFunc

If I start the program a second time, the input is "0"... and not Zeile1, Zeile2, Zeile3

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