Sign in to follow this  
Followers 0
Minikori

Help with my code

9 posts in this topic

#1 ·  Posted (edited)

I don't know why its not working, its for the next version of my keep awake script (which has so many changeable things I need to add the save function). Here's the code I have for the save parts:

EDIT: Changed the code to what you guys said and it still doesn't work.

If Not FileExists(@TempDir & "Settings.kaf") Then
    _FileCreate(@TempDir & "Settings.kaf")
    $File = FileOpen(@TempDir & "Settings.kaf", 1)
    FileWriteLine($File, "Regular")
    FileWriteLine($File, "1")
    FileWriteLine($File, "")
    FileWriteLine($File, "left")
    FileWriteLine($File, "1")
    FileWriteLine($File, "|")
    FileClose($File)
EndIf

...

If $SaveChk = $GUI_CHECKED Then
    $TimeSet = GUICtrlRead($Time)
    $CustomTimeSet = GUICtrlRead($CustomTimeInp)
    $Pixels = GUICtrlRead($UpDown)
    $KeySave = GUICtrlRead($KeyCom)
    _FileCreate(@TempDir & "Settings.kaf")
    $File = FileOpen(@TempDir & "Settings.kaf", 1)
    FileWriteLine($File, $TimeUse)
    FileWriteLine($File, $TimeSet)
    FileWriteLine($File, $CustomTimeSet)
    FileWriteLine($File, $RadSelected)
    FileWriteLine($File, $UpDown)
    FileWriteLine($File, $KeySave)
    FileClose($File)
EndIf

If you need more code to tell what I'm looking for let me know. By the way, I'm not getting AutoIt errors, it's just not saving the changes I guess.

Edited by Minikori

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites



use iniwrite and iniread

I've tried the same exact code (basically) with iniwrite and iniread, it didn't work. Besides, I wanted my own file type.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

You need to close the file in order to see the changes.

IniRead and IniWrite works - if you haven't seen the results then you are surely make a mistake somewhere.

Another thing - your FileWriteLine calls are not correct. FileOpen returns a file handle to use later - I can't see any handle.

$MyFile = FileOpen(@TempDir & "Settings.kaf", 1)
    FileWriteLine($MyFile, "Regular")
...
FileClose($MyFile)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

You need to close the file in order to see the changes.

IniRead and IniWrite works - if you haven't seen the results then you are surely make a mistake somewhere.

Another thing - your FileWriteLine calls are not correct. FileOpen returns a file handle to use later - I can't see any handle.

$MyFile = FileOpen(@TempDir & "Settings.kaf", 1)
    FileWriteLine($MyFile, "Regular")
...
FileClose($MyFile)
Thank you so much!

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

Edited the first post, please view.


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Its hard to tell you whats going wrong when we don't have the full code. For instance, what is the $SaveChk variable? I assume its a handle to checkbox, but I have no idea what it truely is without the full code. Are you even sure that the If $SaveChk = $GUI_CHECKED condition is ever being met? If its a handle then you should be using If GUICtrlRead($SaveChk) = $GUI_CHECKED.

Also, you have no error checking whatsoever. You should be checking to see if the file is ever opened/created, i.e.

$File = FileOpen(@TempDir & "Settings.kaf", 2)
If $File = -1 Then ConsoleWrite("!> Error: Unable to open file (" & @TempDir & "Settings.kaf)" & @LF)

P.S. You don't have to use _FileCreate. FileOpen will create the file if it does not exist.

Edited by zorphnog

Share this post


Link to post
Share on other sites

Its hard to tell you whats going wrong when we don't have the full code. For instance, what is the $SaveChk variable? I assume its a handle to checkbox, but I have no idea what it truely is without the full code. Are you even sure that the If $SaveChk = $GUI_CHECKED condition is ever being met? If its a handle then you should be using If GUICtrlRead($SaveChk) = $GUI_CHECKED.

Also, you have no error checking whatsoever. You should be checking to see if the file is ever opened/created, i.e.

$File = FileOpen(@TempDir & "Settings.kaf", 2)
If $File = -1 Then ConsoleWrite("!> Error: Unable to open file (" & @TempDir & "Settings.kaf)" & @LF)

P.S. You don't have to use _FileCreate. FileOpen will create the file if it does not exist.

Thank you again, I will try this, and the $SaveChk is a GUICtrlCreateCheckBox.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

It works! My problem was that I need a GUICtrlRead(), thanks. but not, the $PixelSave always saves as 19, anyone know why?

EDIT: Fixed it.

Edited by Minikori

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

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