Sign in to follow this  
Followers 0
GWmellon

One Last Problem (First script)

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

GUICtrlSetData($Combo1, $Vesselnameused1 )

3.2.3.7 XP sp2

worked for me

8)

EDIT: worked with 3.2.3.10

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Works here to... Might be a special char in your customers.txt

Posted Image


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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

i get

C:\Documents and Settings\cammy\Desktop\New AutoIt v3 Script (3).au3 (15) : ==> Subscript used with non-Array variable.:

For $x = 1 to $Vesselname[0]

For $x = 1 to $Vesselname^ ERROR


some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

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