Jump to content

Recommended Posts

Posted (edited)

One statement of GUICtrlRead() fails. Result is always "Long/Short" in written file.

The other GUICtrlRead() calls work as expected

Func GetScanSettings() ; Read User Input for scan

Local $collectusername, $collectlot, $collectsample

$UserFile = "Sample.dat" ; Global $UserFile = save this scan's parameters
$datafile = FileOpen($UserFile)
 If( $datafile <> -1) Then
  $collectusername = FileReadLine($datafile, 1)
 EndIf
FileClose($datafile)

; now open a new 'clean' file..
$datafile = FileOpen($UserFile,$FO_OVERWRITE )

;Create GUI
$Main = GUICreate('Enter Sample Detail', 500, 500)

Opt("GUICoordMode",1)

If( $collectusername <> "") Then
   $username = GUICtrlCreateInput($collectusername,100,20,100,20)
 Else
   $username = GUICtrlCreateInput('',100,20,100,20)
 EndIf
$usernamelabel = GUICtrlCreateLabel('Username',30,22)
$FileName = GUICtrlCreateInput("",100,45,100,0)
$FileNamelabel = GUICtrlCreateLabel('File Name',30,47)
$BatchNum = GUICtrlCreateInput("",100,65,100,0)
$BatchNumlabel = GUICtrlCreateLabel('Lot',30,72)
$SampleNum = GUICtrlCreateInput("",100,85,100,0)
$SampleNumlabel = GUICtrlCreateLabel('Sample',30,97)
$SampleLS = GUICtrlCreateInput("",100,105,100,0)
$SampleNumLS = GUICtrlCreateLabel('Long/Short',30,117)

$Button_1 = GUICtrlCreateButton ("OK", 190, 170, 0, 0, 0x0001)

GUISetState (); Run the GUI until the dialog is closed

While 1
    $msg = GUIGetMsg()  ; complete data entries
    Select
        Case $msg = $Button_1
            $collectusername = GUICtrlRead($username)
            WinSetState('Collect Username','',@SW_HIDE)
            $collectfilename = GUICtrlRead($FileName)
            $collectlot = GUICtrlRead($BatchNum)
            $collectsample = GUICtrlRead($SampleNum)
            $collectLS = GUICtrlRead($SampleNumLS)

;           Do
;              $collectLS = GUICtrlRead($SampleNumLS)
;             If $collectLS <> 'Long' And $collectLS <> 'Short' Then
;               Soundplay("Windows XP Error.wav", 1)
;               $collectLS = ""
;             EndIf
;           Until $collectLS = 'Long' Or $collectLS = 'Short'

          ExitLoop
    EndSelect
Wend
    GUIDelete($Main)
 FileWrite($datafile,$collectusername & @CRLF & $collectfilename & @CRLF & $collectlot _
           & @CRLF & $collectsample & @CRLF & 'Long' & @CRLF ) ; $collectLS & @CRLF)
 FileClose($datafile)

EndFunc ;<=== GetScanSettings ==================

I also tried to force user to enter either 'Short' or 'Long' but I got that wrong also :(

The final FileWrite() edited so I do have a correct result.

sample.dat

Pete
FilenamePete
Num1
Samp2
Long/Short

 

Edited by fopetesl
Typo!

The most powerful number in the Universe.  Zero.

Posted
4 minutes ago, Subz said:

Your reading the label not the input.

Oops! Thanks.

Now how do I force user to enter either Short or Long?

The most powerful number in the Universe.  Zero.

Posted
2 minutes ago, LerN said:
$collectLS = GUICtrlRead($SampleLS)

 

Yeah. Works. A lesson in being more careful in naming variables!

Now. Forcing user input?

The most powerful number in the Universe.  Zero.

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
×
×
  • Create New...