Jump to content

iniwrite troubles


Recommended Posts

Hi all,

I'm having some iniwrite problems with the following script:

If Not FileExists("docenten") Then
DirCreate("Docenten") 
EndIf
For $h = 1 To 30
If Eval("new_docent" & $h) = "" Then ContinueLoop 
IniWrite("docenten\" & Eval("new_docent" & $h) & ".ini", "Algemeen", "Wachtwoord", "Cn5rVdt#s")
Next
MsgBox(64, "Cijfer Registratie Systeem | Melding", "Docent(en) toegevoegd")oÝ÷ ØZ½íôznµº1zÌ"¶¯j¸nW­«b²·vë".Ëk·vØ^Ó~§{hqéí½ªâi¹^N©®åzh¬¶­¶P-®ZÞi×îËb¢x¬jÊǦ¦Ü°éî±çbÈzØ^~å¢VéȦëZÈ£î²ÖÞ~Þ¶¢¹h¢ zÛaz¸ ÛÚ笶·÷Múì¡Ç§´ÕDG7öö«¦åzÆ«y×w)¶¬jëh×6$new_docent30 = GUICtrlRead($docent30)

The weird thing is that the return value is always 0 when used INSIDE the loop. Does somebody know why this happens?

Link to comment
Share on other sites

shouldn't it be

If Eval("$new_docent" & $h) = "" Then ContinueLoop

IniWrite("docenten\" & Eval("$new_docent" & $h) & ".ini", "Algemeen", "Wachtwoord", "Cn5rVdt#s")

Just added $ before new_docent.

that's where I think the error is since you say that the value for $new_docent30 = GUICtrlRead($docent30)

Edited by Overlord
Link to comment
Share on other sites

shouldn't it be

Just added $ before new_docent.

that's where I think the error is since you say that the value for $new_docent30 = GUICtrlRead($docent30)

Not in this case. You wouldn't insert the $ manually as Eval() will, well, evaluate the data and interpret it as a variable after processing the string data.

i.e.,

Eval("firststring" & "secondstring")

would be interpreted as $firststringsecondstring

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Hi,

you are sure that

If Not FileExists("docenten") Then
    DirCreate("Docenten") 
EndIf
MsgBox (0,"", $new_docent30) ; this msgbox shows another value then......
For $h = 1 To 30
    If $h = 30 Then MsgBox (0,"",Eval("new_docent" & $h)) ; this one???
    If Eval("new_docent" & $h) = "" Then ContinueLoop 
    IniWrite("docenten\" & Eval("new_docent" & $h) & ".ini", "Algemeen", "Wachtwoord", "Cn5rVdt#s")
Next
MsgBox(64, "Cijfer Registratie Systeem | Melding", "Docent(en) toegevoegd"

If yes, sorry, i can't help further.

;-((

Stefan

Edited by 99ojo
Link to comment
Share on other sites

  • Moderators

PcExpert,

The following works for me:

GUICreate("Test", 300, 300)

$docent1 = GUICtrlCreateInput("", 10, 10, 200, 20)
$docent2 = GUICtrlCreateInput("test", 10, 40, 200, 20)

$new_docent1 = GUICtrlRead($docent1)
$new_docent2 = GUICtrlRead($docent2)

GUISetState()

For $h = 1 To 2
    ConsoleWrite("Before: docent" & $h & " : " & GUICtrlRead(Eval("docent" & $h)) & " - $new_Docent" & $h & " : " & Eval("new_docent" & $h) & @CRLF)
    If GUICtrlRead(Eval("docent" & $h)) = "" Then ContinueLoop
    ConsoleWrite("After : docent" & $h & " : " & GUICtrlRead(Eval("docent" & $h)) & " - $new_Docent" & $h & " : " & Eval("new_docent" & $h) & @CRLF)
Next

Exit

It reads the docent1/2 input values into the new_docent1/2 variables. It then runs the For...Next loop and shows the values of the relevant input box and the $new_docent variable. If there is something in the input it then rewrites the values. I get the correct values regardless of the input values and from both the GUICtrlRead and direct from the previously set variable.

I hope this helps - if not let me have the full script. I have plenty of vakken space left on my drive (private joke)!

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

Hi all,

I'm having some iniwrite problems with the following script:

If Not FileExists("docenten") Then
    DirCreate("Docenten")
EndIf
For $h = 1 To 30
    If Eval("new_docent" & $h) = "" Then ContinueLoop
    IniWrite("docenten\" & Eval("new_docent" & $h) & ".ini", "Algemeen", "Wachtwoord", "Cn5rVdt#s")
Next
MsgBox(64, "Cijfer Registratie Systeem | Melding", "Docent(en) toegevoegd")

I have 30 inputboxes with a variable that is read using guictrlread (the $new_docent variable). The problem is that the GUIctrlread() function is always empty when used inside the for-loop. When I put a msgbox just before the for-loop I get the right values. the '$new_docent[NUMBERHERE]' variables are defined like this:

$new_docent30 = GUICtrlRead($docent30)

The weird thing is that the return value is always 0 when used INSIDE the loop. Does somebody know why this happens?

Dude, we've been here before. You know the control IDs and values should be in arrays, and Eval() is lazy scam to avoid learning arrays.

You should be creating the controls with:

$avDocent[$n] = GuiCtrlCreateInput("", $x, $y, $w, $h)

Then read the values with:

For $h = 1 To 30
    $avNew_docent[$h] = GUICtrlRead($avDocent[$h])
Next

For $h = 1 To 30
    If $avNew_docent[$h] = "" Then ContinueLoop
    IniWrite("docenten\" & $avNew_docent[$h] & ".ini", "Algemeen", "Wachtwoord", "Cn5rVdt#s")
Next

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...