Jump to content

One Last Problem (First script)


Recommended Posts

I have completed my first script and everything is working well. However, I have one problem to clean up. All the other three hundred lines are working well so this will not be a "one more question" topic.

This is my test case code:

#include <GUIConstants.au3>
#include <File.au3>
#Include<Array.au3>
$Vesselname =""
; get the customer list  and put it into an array
_FileReadToArray("c:\customers.txt", $Vesselname)


GUICreate("My GUI"); will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)  
$Button_1 = GUICtrlCreateButton ("Get Module Codes",  250,9, 100)
$Combo1=GUICtrlCreateCombo ("Vessel Name",35,10); create first item

For $x = 1 to $Vesselname[0]
    $Vesselnameused1 = StringReplace($Vesselname[$X], @TAB, " ")
    GUICtrlSetData($Combo1, $Vesselnameused1 & @LF)
Next


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            Beep
            
    EndSelect
WEnd

This should read a text file, one item per line , and put it in a combo. It does but not the way I want it to do so.

This is the problem: GUICtrlSetData($Combo1, $Vesselnameused1 & @LF)

If I remove the @LF nothing gets into the Combo. With the LF the combo is populated but each item has the LF symbol ([]) after it. Also, a @TAB and @CR will work just as well but produce the same symbol. Using most current production release of Autoit (downloaded last night).

Any help?

Edited by GWmellon
Link to comment
Share on other sites

GUICtrlSetData($Combo1, $Vesselnameused1 )

3.2.3.7 XP sp2

worked for me

8)

EDIT: worked with 3.2.3.10

Curious, it still does not work for me. I cut and pasted what you posted. I also tried stripping the CR and LFs but that didn't work either.

However, this does work:

GUICtrlSetData($Combo1,$Vesselnameused1 &" ").

I would suspect that anything added to the end would do the trick. This is only going to be used inhouse so this fix will be good enough to release the rest of the project to the beta testers.

BTW, I am using v3.2.2.0 which should be the latest production release.

Edited by GWmellon
Link to comment
Share on other sites

Instead of:

For $x = 1 to $Vesselname[0]
    $Vesselnameused1 = StringReplace($Vesselname[$X], @TAB, " ")
    GUICtrlSetData($Combo1, $Vesselnameused1 & @LF)
Next
oÝ÷ ÚÚò¶¬jëh×6$Vesselnameused1 = ''
For $x = 1 to $Vesselname[0]
    $Vesselnameused1 &= StringReplace($Vesselname[$X], @TAB, " ") & '|'
Next
$Vesselnameused1 = StringTrimRight($Vesselnameused1,1)
GUICtrlSetData($Combo1, $Vesselnameused1)
Link to comment
Share on other sites

Sounds like the file is not loaded then.. Does your customer.txt contain more than on line ??? Does it exsist ?? Try to get an output from $vessel

#include <GUIConstants.au3>
#include <File.au3>
#Include<Array.au3>
$Vesselname =""
; get the customer list  and put it into an array
_FileReadToArray("c:\customers.txt", $Vesselname)
MsgBox(0,0,$Vesselname[0])

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Link to comment
Share on other sites

Removed the space in the script and added a couple of testers. Both the testers get the list in the combo box without a problem. With the next release I am going to give everyone a version without the space. I am beginning to suspect that the problem is caused by something flaky in the machine.

Thanks for the suggestions. With a bit of luck I won't be back to this message :)

Edited by GWmellon
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...