Jump to content
Sign in to follow this  
Senach

Curse of the magic numbers

Recommended Posts

Senach

Greetings again from an old dog trying to learn new tricks :)

Brief explanation of this script: I work at a library and am trying to create an way to easily input (and later make changes to) what on each aisle and save it to a text file which would then be used to link items in our catalog to the aisle theyre on.

Anyway, I got the gui input setup, and with some help from you all, the FileWrite working when I tested it using constants for variables. But when I try and use the stuff inputted from the gui, I get numbers.

Heres the script:

#include <GUIConstants.au3>

GUICreate(" My GUI input acceptfile", 560,550, @DesktopWidth/2-260, @DesktopHeight/2-315, $WS_VSCROLL, 0x00000018); WS_EX_ACCEPTFILES

GUICtrlCreateLabel("Enter information for whats down each aisle choosing the location and then entering ", 28, 10)
GUICtrlCreateLabel("the first letter of the call # for fiction or the 3 digit call # for non-fiction", 28,30)
GUICtrlCreateLabel("Use the 2nd and 3rd lines if multiple locations are on a paticular aisle.", 28,50)

GUICtrlCreateLabel("Aisle", 10,70)
GUICtrlCreateLabel("Location", 70,70)
GUICtrlCreateLabel("Start of Aisle", 300,70)
GUICtrlCreateLabel("End of Aisle", 420,70)

;aisle 1
    GUICtrlCreateLabel("1", 10,90)
;location
    $loc1 = GUICtrlCreateCombo ("", 70,90, 200, 20)
    GUICtrlSetData(-1,"Jaa JC Adult Audiovisual| jaas JC Adult Spanish Audiovisual| jab JC Adult Biography| jac JC Adult Science Fiction| jacf JC Adult Christian Fict| jad JC Adult Display| jaf JC Adult Fiction| jag JC Adult Graphic Novel| jai JC Adult Walk-In| jaj Periodical Prf Collection| jak JC Adult Book Club| jal JC Adult Large Print| jam JC Adult Missouri| jamg JC Adult Genealogy| jamgo JC Adult Genealogy Ovrsz| ", "")
;start of aisle
    $start1 = GUICtrlCreateInput ( "", 300,  90, 100, 20)
    GUICtrlSetState(-1,$GUI_DROPACCEPTED)
;end of aisle
    $end1 = GUICtrlCreateInput ("", 420,  90, 100, 20)

;aisle 1a
        GUICtrlCreateLabel("1a", 20,115)
    ;location
        $loc1a = GUICtrlCreateCombo ("", 70,115, 200, 20)
        GUICtrlSetData(-1,"Jaa JC Adult Audiovisual| jaas JC Adult Spanish Audiovisual| jab JC Adult Biography| jac JC Adult Science Fiction| jacf JC Adult Christian Fict| jad JC Adult Display| jaf JC Adult Fiction| jag JC Adult Graphic Novel| jai JC Adult Walk-In| jaj Periodical Prf Collection| jak JC Adult Book Club| jal JC Adult Large Print| jam JC Adult Missouri| jamg JC Adult Genealogy| jamgo JC Adult Genealogy Ovrsz| ", "")
    ;start of aisle
        $start1a = GUICtrlCreateInput ( "", 300,  115, 100, 20)
        GUICtrlSetState(-1,$GUI_DROPACCEPTED)
    ;end of aisle
        $end1a = GUICtrlCreateInput ("", 420,  115, 100, 20)

;aisle 1b
        GUICtrlCreateLabel("1b", 20,140)
    ;location
        $loc1b = GUICtrlCreateCombo ("", 70,140, 200, 20)
        GUICtrlSetData(-1,"Jaa JC Adult Audiovisual| jaas JC Adult Spanish Audiovisual| jab JC Adult Biography| jac JC Adult Science Fiction| jacf JC Adult Christian Fict| jad JC Adult Display| jaf JC Adult Fiction| jag JC Adult Graphic Novel| jai JC Adult Walk-In| jaj Periodical Prf Collection| jak JC Adult Book Club| jal JC Adult Large Print| jam JC Adult Missouri| jamg JC Adult Genealogy| jamgo JC Adult Genealogy Ovrsz| ", "")
    ;start of aisle
        $start1b = GUICtrlCreateInput ( "", 300,  140, 100, 20)
        GUICtrlSetState(-1,$GUI_DROPACCEPTED)
    ;end of aisle
        $end1b = GUICtrlCreateInput ("", 420,  140, 100, 20)


$btn = GUICtrlCreateButton ("Ok", 20,  485, 60, 20)

GUISetState () 

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $btn
               exitloop
       EndSelect
Wend

$file = FileOpen("C:\scripts\test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, $loc1 & " , " & $start1 & " , " & $loc1a & " , " & $start1a & " , " & $end1a & _
        " , " & $loc1b & " , " & $start1b & " , " & $end1b & " , " & $end1 & @CRLF)

FileClose($file)

And heres what I get written in the file:

11 , 12 , 15 , 16 , 17 , 19 , 20 , 21 , 13

If someone would take pity on me and please explain what I did wrong, and where these numbers are coming from, I would greatly appreciate it.

Thanks


"The three rules of the Librarians of Time and Space are: 1) Silence; 2) Books must be returned no later than the date last shown; and 3) Do not interfere with the nature of causality." Terry Pratchett - The Light Fantastic

Share this post


Link to post
Share on other sites
GEOSoft

You have to use GUICtrlRead()

FileWrite($file, GUICtrlRead($loc1) & " , " & GUICtrlRead($start1) & " , " & GUICtrlRead($loc1a) & " , " & GUICtrlRead($start1a) & " , " & GUICtrlRead($end1a) & _
        " , " & GUICtrlRead($loc1b) & " , " & GUICtrlRead($start1b) & " , " & GUICtrlRead($end1b) & " , " & GUICtrlRead($end1) & @CRLF)

FileClose($file)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
The Ape

You're not reading the data of the control. So... I assume when you try to write to file, you are simply getting a reference id to the control.

Edit: GEOSoft... quick draw.

Edited by The Ape

Share this post


Link to post
Share on other sites
Senach

Thank you both. I knew it was something that I just was forgetting to put in there, I just couldn't find any examples that would tell me what.

Anyway, Thanks again!


"The three rules of the Librarians of Time and Space are: 1) Silence; 2) Books must be returned no later than the date last shown; and 3) Do not interfere with the nature of causality." Terry Pratchett - The Light Fantastic

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.