PDA

View Full Version : What's wrong here?



ReneMiner
30-10-2012, 22:48
If I just put this function into my code, execution stops immediately, this function doesn't even get called!
gives strange Error-Description of missing Endif and starts a File-IO-Dialog
The CodeWindow gets screwed up, adds countless empty new lines and the code disappears finally



Function isNumeric(aString As String) As Long
' find out if aString contains just numerals and -.,
Local lCount, lLong As Long

If Len(aString) = 0
isNumeric = FALSE
Exit Function
EndIf

For lCount = 1 To Len(aString)
lLong = Asc(aString,lCount)
If lLong < 48 Or lLong > 57 Then
If lLong <> 43 And llong <> 45 And lLong <> 46 Then
isNumeric = FALSE
Exit Function
EndIf
EndIf
Next lCount

isNumeric = TRUE

End Function

Edit: found out "THEN" in 3rd line is missing. Can't it just tell that instead of messing everything up? Thank goodness I had a backup...

ErosOlmi
30-10-2012, 23:08
Here it just give error "IF Without End IF" without messing up any code.
I can improve error handling trying to determine correct line position. I will see what I can do in next versions.


See also Verify function, it can help for quick verify like:
Verify("123.5", "0123456789.")
See help at http://www.thinbasic.com/public/products/thinBasic/help/html/index.html?verify.htm

Petr Schreiber
30-10-2012, 23:15
On my PC it behaves as Eros describes.


Petr

ReneMiner
31-10-2012, 00:41
@Petr: try to copy this into my listing. that was the only change...

@Eros: how about getting rid of keyword "THEN" for this case

if X = 1
' do this
elseif X = 2
'do that
endif

and

if X = 1 then Y = 2

so THEN signals one-line-if-conditions.