Sign in to follow this  
Followers 0
jammzhentai450

Numbers. AAAHHHHH!

4 posts in this topic

I have a script that sets stuff in an inc file by means like textboxes.

I get numbers in the ini file and the code also means that you can see the settings.

Here is the code:

#include <GUIConstantsEx.au3>
$var1 = IniRead ("UserVariables.inc", "Variables", "Folder", "")
$var2 = IniRead ("UserVariables.inc", "Variables", "Subfolders", "")
$var3 = IniRead ("UserVariables.inc", "Variables", "Language", "")
$var4 = IniRead ("UserVariables.inc", "Variables", "CustomText", "")
$Action = IniRead ("settings.inc", "Refresh", "Command", "")
Opt("TrayIconHide", 1)
opt("GUIOnEventMode", 1)
$GUI = GUICreate("Configuration", 500, 235)
GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Close" )
$Label = GUICtrlCreateLabel("Location of the slideshow:", 10, 10)
$Folder = GuiCtrlCreateInput("", 10, 30, 230, 20)
$checkSubFolder = GUICtrlCreateCheckbox("Enable Subfolders", 250, 60, 105, 20)
GUICtrlCreateGroup("Language (Not working yet)", 10, 55, 230, 80)
$Lang1 = GUICtrlCreateRadio("English", 20, 75, 60, 20)
$Lang2 = GUICtrlCreateRadio( "More soon", 20, 95, 100, 20)
GUICtrlSetState($Lang1, $GUI_CHECKED)
$Lang = GUICtrlRead($Lang1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
GUICtrlCreateGroup("Current Settings", 250, 80, 230, 120)
$Sett1 = GUICtrlCreateLabel("Folder: " & $Var1, 260, 100)
$Sett2 = GUICtrlCreateLabel("Subfolders: " & $Var2, 260, 120)
$Sett3 = GUICtrlCreateLabel("Language: " & $Var3, 260, 140)
$Sett4 = GUICtrlCreateLabel("Username: " & $Var4, 260, 160)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
$Label2 = GUICtrlCreateLabel("Custom Username:", 250, 10)
$CustomText = GuiCtrlCreateInput("", 250, 30, 230, 20)
$Verify = GuiCtrlCreateButton("Cancel", 420,205,70,25)
GUICtrlSetOnEvent ( $Verify, '_Close' )
$Cancel = GuiCtrlCreateButton("OK", 345,205,70,25)
GUICtrlSetOnEvent ( $Verify, '_FolderWrite' )
GUISetState(@SW_SHOW)
While 1
    Sleep ( 20 )
WEnd
Func _FolderWrite ( )
    IniWrite ( "UserVariables.inc", "Variables", "Folder", $Folder )
IniWrite ( "UserVariables.inc", "Variables", "Subfolders", $checkSubFolder )
IniWrite ( "UserVariables.inc", "Variables", "Language", $Lang )
IniWrite ( "UserVariables.inc", "Variables", "CustomText", $CustomText )
ShellExecute("refresh.exe", $Action)
EndFunc

Func _Close ( )
    Exit
EndFunc

any help on the iniwrite parts

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What is the problem you have with your code?

- If its about numbers/values being returned as strings when pulling them out of the ini file. That is a feature of ini files. And you need to take care of the string to value conversion. (although that's ini-read related.)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

no. I set text in the textboxes, press the button that sets the text in the textboxes into the .inc file and it ends up as numbers in the .inc file.

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>

Opt("TrayIconHide", 1)
opt("GUIOnEventMode", 1)

$var1 = IniRead ("UserVariables.inc", "Variables", "Folder", "")
$var2 = IniRead ("UserVariables.inc", "Variables", "Subfolders", "")
$var3 = IniRead ("UserVariables.inc", "Variables", "Language", "")
$var4 = IniRead ("UserVariables.inc", "Variables", "CustomText", "")
$Action = IniRead ("settings.inc", "Refresh", "Command", "")

$GUI = GUICreate("Configuration", 500, 235)
GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Close" )
$Label = GUICtrlCreateLabel("Location of the slideshow:", 10, 10)
$Folder = GuiCtrlCreateInput("", 10, 30, 230, 20)
$checkSubFolder = GUICtrlCreateCheckbox("Enable Subfolders", 250, 60, 105, 20)
GUICtrlCreateGroup("Language (Not working yet)", 10, 55, 230, 80)
$Lang1 = GUICtrlCreateRadio("English", 20, 75, 60, 20)
$Lang2 = GUICtrlCreateRadio( "More soon", 20, 95, 100, 20)
GUICtrlSetState($Lang1, $GUI_CHECKED)
;~ $Lang = GUICtrlRead($Lang1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
GUICtrlCreateGroup("Current Settings", 250, 80, 230, 120)
$Sett1 = GUICtrlCreateLabel("Folder: " & $Var1, 260, 100)
$Sett2 = GUICtrlCreateLabel("Subfolders: " & $Var2, 260, 120)
$Sett3 = GUICtrlCreateLabel("Language: " & $Var3, 260, 140)
$Sett4 = GUICtrlCreateLabel("Username: " & $Var4, 260, 160)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
$Label2 = GUICtrlCreateLabel("Custom Username:", 250, 10)
$CustomText = GuiCtrlCreateInput("", 250, 30, 230, 20)
$Verify = GuiCtrlCreateButton("Cancel", 420,205,70,25)
GUICtrlSetOnEvent ( $Verify, '_Close' )
$Cancel = GuiCtrlCreateButton("OK", 345,205,70,25)
GUICtrlSetOnEvent ( $Verify, '_FolderWrite' )
GUISetState(@SW_SHOW)

While 1
    Sleep ( 20 )
WEnd

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

Func _FolderWrite ( )
    IniWrite ( "UserVariables.inc", "Variables", "Folder", GUICtrlRead($Folder) )
    IniWrite ( "UserVariables.inc", "Variables", "Subfolders", IsChecked($checkSubFolder))
    IniWrite ( "UserVariables.inc", "Variables", "Language", IsChecked($Lang1) )
    IniWrite ( "UserVariables.inc", "Variables", "CustomText", GUICtrlRead($CustomText))
    ShellExecute("refresh.exe", $Action)
EndFunc

Func _Close ( )
    Exit
EndFunc

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