Jump to content

Listbox / FileReadLine Problem


Recommended Posts

This one's driving me up the wall. Here is part of the code from a function that is supposed to create a listbox from data in another file:

;----------------------------------------------------------------------------------------------------------------------------
; GUI CREATION-


; Create the GUI window:
    GUICreate ($title, 400, 430)
        If @error = 1 Then
            ErrorFunc ("The Versions Interface Window failed to initialize.", "ListVer-GUICreate")
        EndIf

; Create instructional text:
    GUICtrlCreateLabel ($insttext, 25, 10, 350, 50)


;----------------------------------------------------------------------------------------------------------------------------
; CREATE VERSION LIST-


; Create listbox:
    $verlist = GUICtrlCreateList ("", 25, 50, 350, 300)
    GUICtrlSetState (-1, $GUI_FOCUS)

; Open \Data\Versions.dat file:
    $file = FileOpen (@ScriptDir & "\Data\Versions.dat", 0)
        If $file = -1 Then
            ErrorFunc ("Unable to open file " & @ScriptDir & "\Data\Versions.dat", "ListVer-FileOpen")
        EndIf

; Create list of all versions:
        While 1
            $version = FileReadLine ($file, $line)
                If @error Then
                    ExitLoop
                EndIf
            GUICtrlSetData ($verlist, $version)
            $line = ($line + 5)
        Wend

; Close the Versions.dat file
    FileClose ($file)

And here is part of the file it is reading from:

; (Line 20):
F4_ZZ_UNKNOWN
Falcon 4.0 - Unknown Version
Falcon 4

; (Line 25):
F4
Falcon 4.0
Falcon 4

; (Line 30):
F4_US_108
Falcon 4.0 - 1.08
Falcon 4

; (Line 35):
F4_US_FF200
Falcon 4.0 - FreeFalcon 2
Falcon 4 FF2

When the function is called to begin reading at line 21, "Falcon 4.0 - Unknown Version", the listbox that is created skips the data on line 26, "Falcon 4.0". If I change line 26 to something else like, "Nothing", then it will show up on the list. If I leave it the way it is and start reading from line 26, then "Falcon 4.0" does show up. Why does this get skipped when I start from 21? If it helps answer the question, all of the return data begins with "Falcon 4.0".

-DRX
Link to comment
Share on other sites

Try amending this line to increment by 6 not 5. (or 5 to 4)

$line = ($line + 6)

HTH

HardCopy

ps your line numbering example is not to clear, is this:

; (Line 20):
F4_ZZ_UNKNOWN

1 line or 2 lines of data?

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

With some modifications (since you didn't post your whole code), I was able to get your script to work perfectly--reading from the file every five lines down until the end of the file.

If you post the whole script, perhaps someone will be able to better assist you in figuring out where in your script the problem lies since the problem is likely to be elsewhere in your script.

Link to comment
Share on other sites

@HardCopy- Sorry for the confusion. The line in the .dat file that says ";(Line ##):" is just a reference in the file to mean that the following line is that line number. I just put that in there to double-check myself to make sure everything stays where it is supposed to. The data that the function is looking for does increment every 5 lines.

@SerialKiller- Jeez, my script is currently 3000+ lines. Posting the whole thing just wouldn't be practical.

Here's the whole function though:

;################################################################################################

############################
;
; 
; ListVer Function  !!!NF!!!  (This skips line 26 if called from line 21 for some reason)
;
;
; Revision 0
; Last Edited August 30, 2005 for Falcon 4 Dance Partner version 1.1
; Written by David C. Reynolds
;
; - Creates a list menu of all compatible versions
;
; - Dependant Functions:
;    <GUIConstants.au3>
;    ErrorFunc
;
; - Input Variables:
;    $title        The title of the menu
;    $insttext    Instructional text
;    $line        The line in Versions.dat to start reading
;
; - Output Returns:
;    $output        The name of the version selected
;    "0" if unsuccessful
;
;
;###################################################################################################

#########################


;----------------------------------------------------------------------------------------------------------------------------
; BEGIN LISTVER FUNCTION-


    Func ListVer ($title, $insttext, $line)


;----------------------------------------------------------------------------------------------------------------------------
; DECLARE LOCAL VARIABLES-


; Title of the GUI window:
    Local $title

; Instructional text at top of window:
    Local $insttext

; Line in Versions.dat file to start reading:
    Local $line

; Control handle for the listbox:
    Local $verlist

; Control handle for the Versions.dat file:
    Local $file

; Text of the version info read:
    Local $version

; Control number of the Select button:
    Local $select

; Control number of the Cancel button:
    Local $cancel

; The name of the version selected:
    Local $output


;----------------------------------------------------------------------------------------------------------------------------
; GUI CREATION-


; Create the GUI window:
    GUICreate ($title, 400, 430)
        If @error = 1 Then
            ErrorFunc ("The Versions Interface Window failed to initialize.", "ListVer-GUICreate")
        EndIf

; Create instructional text:
    GUICtrlCreateLabel ($insttext, 25, 10, 350, 50)


;----------------------------------------------------------------------------------------------------------------------------
; CREATE VERSION LIST-


; Create listbox:
    $verlist = GUICtrlCreateList ("", 25, 50, 350, 300)
    GUICtrlSetState (-1, $GUI_FOCUS)

; Open \Data\Versions.dat file:
    $file = FileOpen (@ScriptDir & "\Data\Versions.dat", 0)
        If $file = -1 Then
            ErrorFunc ("Unable to open file " & @ScriptDir & "\Data\Versions.dat", "ListVer-FileOpen")
        EndIf

; Create list of all versions:
        While 1
            $version = FileReadLine ($file, $line)
                If @error Then
                    ExitLoop
                EndIf
            GUICtrlSetData ($verlist, $version)
            $line = ($line + 5)
        Wend

; Close the Versions.dat file
    FileClose ($file)


;----------------------------------------------------------------------------------------------------------------------------
; CREATE GUI BUTTONS-


; Create Select button:
    $select = GUICtrlCreateButton ("Select Version", 25, 360, 350)
        GUICtrlSetState (-1, $GUI_DISABLE)

; Create Cancel button:
    $cancel = GUICtrlCreateButton ("Cancel", 25, 385, 350)

; Show the GUI:
    GUISetState (@SW_SHOW)


;----------------------------------------------------------------------------------------------------------------------------
; AWAIT USER INPUT-

; Await User Input to define action to take:
        While 1
            $msg = GUIGetMsg ()
                Select
                    Case $msg = $GUI_EVENT_CLOSE
                        GUIDelete ($title)
                        Return 0
                    Case $msg = $cancel
                        GUIDelete ($title)
                        Return 0
                    Case (($msg = $verlist) AND (GUICtrlRead ($verlist) <> ""))
                        GUICtrlSetState ($select, $GUI_ENABLE)
                    Case $msg = $select
                        $output = GUICtrlRead ($verlist)
                        ExitLoop
                EndSelect
        Wend


;----------------------------------------------------------------------------------------------------------------------------
; END LISTVER FUNCTION-


    GUIDelete ($title)
    Return $output
    EndFunc

And here is the entire Versions.dat file:

;===========================================================================
;
; Falcon 4 Dance Partner Supported Version Data (Versions.dat)
;
;
; Format:    
;    F4DP Version Code
;    Version Name
;    Shortcut Name
;
;===========================================================================


; (Line 15):
F4_ZZ_NONE
No Active Version
Falcon 4

; (Line 20):
F4_ZZ_UNKNOWN
Falcon 4.0 - Unknown Version
Falcon 4

; (Line 25):
F4
Falcon 4.0
Falcon 4

; (Line 30):
F4_US_108
Falcon 4.0 - 1.08
Falcon 4

; (Line 35):
F4_US_FF200
Falcon 4.0 - FreeFalcon 2
Falcon 4 FF2

; (Line 40):
F4_US_FF200_BMS103
Falcon 4.0 - FreeFalcon 2 - BenchmarkSims 1.03
Falcon 4 FF2-BMS1

; (Line 45):
F4_US_FF200_BMS200
Falcon 4.0 - FreeFalcon 2 - BenchmarkSims 2.0
Falcon 4 FF2-BMS2

; (Line 50):
F4_US_FF210
Falcon 4.0 - FreeFalcon 2.1
Falcon 4 FF2

; (Line 55):
F4_US_FF210_BMS103
Falcon 4.0 - FreeFalcon 2.1 - BenchmarkSims 1.03
Falcon 4 FF2-BMS1

; (Line 60):
F4_US_FF210_BMS200
Falcon 4.0 - FreeFalcon 2.1 - BenchmarkSims 2.0
Falcon 4 FF2-BMS2

; (Line 65):
F4_US_FF300
Falcon 4.0 - FreeFalcon 3
Falcon 4 FF3

; (Line 70):
F4_US_FF300_COB101
Falcon 4.0 - FreeFalcon 3 - Cobra 1.1
Falcon 4 FF3-Cobra1

; (Line 75):
F4_US_FF300_COB111
Falcon 4.0 - FreeFalcon 3 - Cobra 1.1.1
Falcon 4 FF3-Cobra1

; (Line 80):
F4_US_FF301
Falcon 4.0 - FreeFalcon 3.1
Falcon 4 FF3

; (Line 85):
F4_US_FF301_COB101
Falcon 4.0 - FreeFalcon 3.1 - Cobra 1.1
Falcon 4 FF3-Cobra1

; (Line 90):
F4_US_FF301_COB111
Falcon 4.0 - FreeFalcon 3.1 - Cobra 1.1.1
Falcon 4 FF3-Cobra1

; (Line 95):
F4_US_FF311
Falcon 4.0 - FreeFalcon 3.1.1
Falcon 4 FF3

; (Line 100):
F4_US_FF311_COB101
Falcon 4.0 - FreeFalcon 3.1.1 - Cobra 1.1
Falcon 4 FF3-Cobra1

; (Line 105):
F4_US_FF311_COB111
Falcon 4.0 - FreeFalcon 3.1.1 - Cobra 1.1.1
Falcon 4 FF3-Cobra1

; (Line 110):
F4_US_SP300
Falcon 4.0 - SuperPAK 3
Falcon 4 SP3

; (Line 115):
F4_US_SP300_BMS103
Falcon 4.0 - SuperPAK 3 - Benchmark Sims 1.03
Falcon 4 SP3-BMS1

; (Line 120):
F4_US_SP300_BMS200
Falcon 4.0 - SuperPAK 3 - Benchmark Sims 2.0
Falcon 4 SP3-BMS2

; (Line 125):
F4_US_SP300_HF
Falcon 4.0 - SuperPAK 3 - SP3 Hotfix
Falcon 4 SP3

; (Line 130):
F4_US_SP300_HF_BMS103
Falcon 4.0 - SuperPAK 3 - SP3 Hotfix - BenchmarkSims 1.03
Falcon 4 SP3-BMS1

; (Line 135):
F4_US_SP300_HF_BMS200
Falcon 4.0 - SuperPAK 3 - SP3 Hotfix - BenchmarkSims 2.0
Falcon 4 SP3-BMS2

; (Line 140):
F4_US_SP400
Falcon 4.0 - SuperPAK 4
Falcon 4 SP4

; (Line 145):
F4_US_SP400_BMS103
Falcon 4.0 - SuperPAK 4 - BenchmarkSims 1.03
Falcon 4 SP4-BMS1

; (Line 150):
F4_US_SP400_BMS200
Falcon 4.0 - SuperPAK 4 - BenchmarkSims 2.0
Falcon 4 SP4-BMS2

; (Line 155):
F4_US_SP410
Falcon 4.0 - SuperPAK 4.1
Falcon 4 SP4

; (Line 160):
F4_US_SP410_BMS103
Falcon 4.0 - SuperPAK 4.1 - BenchmarkSims 1.03
Falcon 4 SP4-BMS1

; (Line 165):
F4_US_SP410_BMS200
Falcon 4.0 - SuperPAK 4.1 - BenchmarkSims 2.0
Falcon 4 SP4-BMS2

; (Line 170):
F4_US_SP410_DP_BMS103
Falcon 4.0 - SuperPAK 4.1 - BMS Data Patch - BenchmarkSims 1.03
Falcon 4 SP4-BMS1

; (Line 175):
F4_US_SP410_DP_BMS200
Falcon 4.0 - SuperPAK 4.1 - BMS Data Patch - BenchmarkSims 2.0
Falcon 4 SP4-BMS2

; (Line 180):
F4_US_SP420
Falcon 4.0 - SuperPAK 4.2
Falcon 4 SP4

; (Line 185):
F4_US_SP420_BMS103
Falcon 4.0 - SuperPAK 4.2 - BenchmarkSims 1.03
Falcon 4 SP4-BMS1

; (Line 190):
F4_US_SP420_BMS200
Falcon 4.0 - SuperPAK 4.2 - BenchmarkSims 2.0
Falcon 4 SP4-BMS2

; (Line 195):
F4_US_SP420_DP_BMS103
Falcon 4.0 - SuperPAK 4.2 - BMS Data Patch - BenchmarkSims 1.03
Falcon 4 SP4-BMS1

; (Line 200):
F4_US_SP420_DP_BMS200
Falcon 4.0 - SuperPAK 4.2 - BMS Data Patch - BenchmarkSims 2.0
Falcon 4 SP4-BMS2

This is the line in the script that calls the function:

ListVer ("Make Existing Version F4DP Compliant", "Select the name of the existing version from the list below." _
& @CRLF & "If you do not see your version listed, select ""Unknown Version""", 21)

When I run it, it will create a list of every version name except for "Falcon 4.0".

Edited by DoctorX
-DRX
Link to comment
Share on other sites

This is what I got when I ran your script (with minor modifications to get rid of the errors from variables and the ErrorFunc () Function (changed those to Message Boxes))

Is this how it is supposed to look?

Edit: Also, when I said to post your script, I did not mean to necessarily list the code on the page, but to attach it so it can be downloaded. This would probably be best for trouble-shooting.

Edited by SerialKiller
Link to comment
Share on other sites

Yes! What you got is exactly what you are supposed to get. But look what I get:

Posted Image

And now I know it's not a problem in the rest of my script because I pasted the code in my post into a new script and got the same result. So it must be something with my system? How could this be possible?

-DRX
Link to comment
Share on other sites

Yes!  What you got is exactly what you are supposed to get.  But look what I get:

and now I know it's not a problem in the rest of my script because I pasted the code in my post into a new script and got the same result.  So it must be something with my system?  How could this be possible?

Ok u copied the posted code back in, but for the process of elimination, copy and paste the data file posted here too... works for killer should work for you. Could have some control code mixed in somwhere..

HardCopy

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

Alright, tried that... Same result. :whistle:

This is weird. Why would it only be doing this on my system? Hopefully it is only my system. I'll see if my beta testers have the same problem when I send it out to them.

Thanx for all the help anyway.

-DRX
Link to comment
Share on other sites

Alright, tried that...  Same result.  :dance:

This is weird.  Why would it only be doing this on my system?  Hopefully it is only my system.  I'll see if my beta testers have the same problem when I send it out to them. 

Thanx for all the help anyway.

<{POST_SNAPBACK}>

Bummer, Have u tried using your script in both beta and release versions. u didnt state which version you were running it in.

Sorry i couldnt help you resolve this, maybe someone else can, surprised so little traffic passed by to help out. Im sure you'll wake up 3am one morning with a light bulb above your head shouting eureka! :dance:

On a side note , i take it this is for Falcon 4 the flight sim, I bought that game , hmm must be 7 years ago at least, was awesome in its day, i even bought a cheap hotas setup, this game was excellent. Is it still alive and well? Who is developing it now, was formerly microprose i think.

HardCopy :whistle:

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

It's all beta right now. The programs only about halfway finished.

Yes, this is for the F-16 sim Falcon 4.0. The game has come a long way since it was released in December 1998. There are several independant groups that have been modding the game since then and they have created some wonderful enhancement packages. The actual ownership of Falcon 4.0 has changed hands several times and is now owned by Atari/Graphsim who has recently re-released it as Falcon 4.0 - Allied Force.

The "new" version has recieved mixed reviews, but I and many others in the Falcon 4.0 community still prefer the "old" version with the indipendant add-ons. What my program is trying to accomplish is to provide one-click installation for some of the various versions, as well as allow multiple versions to be simultaneously installed.

If your interested, check out some of the following links:

FreeFalcon Group

Falcon UT Group

For everyone else, sorry to get so far OT. :whistle:

-DRX
Link to comment
Share on other sites

@DoktorX: I'm sure that you are not using the beta (or maybe an old beta).

The release version 3.1.1 have this bug but the current beta don't.

If you would use the beta you would get an error at:

Func ListVer ($title, $insttext, $line)


;----------------------------------------------------------------------------------------------------------------------------
; DECLARE LOCAL VARIABLES-


; Title of the GUI window:
    Local $title

; Instructional text at top of window:
    Local $insttext

that you cannot redeclare a variable in user function!

Regards

Holger

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...