Jump to content

Problem with Number function


Go to solution Solved by Nine,

Recommended Posts

Hello everyone,

I'm a new user of Autoit and my first post is with the Number() function.

I have a text file with differents values

A;2
A;2.78
A;"3.9"
A;"3.11"
A;"3.11"
A;7.9
A;N/A
A;N/A
A;N/A
A;7.95
A;8.04
A;8.10
A;8.22
A;8.15
A;8.15
A;8.15
A;9.6
A;9.44
A;"9.59"
A;11
A;14
A;15
A;15.6
A;N/A
A;15.88

I tested the IsNumber() function but it doesn't work with quotes "". If I use Number()  and after IsNumber(), N/A return 1. I don't understand...

 

Link to comment
Share on other sites

  • Moderators

Welcome to the forum @_Func. Can you please post the code you're using? There are, as with most languages, innumerable ways to skin the proverbial cat; seeing how you are going about this process will help us help you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

$file = @DesktopDir & "\Data.txt"

$hFileOpen = FileOpen($file, 0)

If $hFileOpen = -1 Then
    MsgBox(16, "Erreur", "Impossible d'ouvrir le fichier.")
    Exit
EndIf

While True
    Local $line = FileReadLine($hFileOpen)
    If @error = -1 Then ExitLoop
    $result = StringTrimLeft($line, 2)

    If IsNumber(Number($result)) Then
;~  If IsFloat($result) Then
        ConsoleWrite("$result :" & $result & @LF)
    EndIf
WEnd

FileClose($hFileOpen)

 

Link to comment
Share on other sites

  • Solution
Link to comment
Share on other sites

@_Func ? : are a shorter way for inline if then else

  $aList[$i] = IsArray($aTemp) ? Number($aTemp[0]) : 0

is

; something similar to this
$aList[$i] = somefunc()
Func somefunc()
  If IsArray($aTemp) Then return Number($aTemp[0])
  return 0
EndFunc

https://www.autoitscript.com/autoit3/docs/keywords/Ternary.htm

 

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Here's something to keep in mind regarding data types and comparing them (or even checking if they are a specific type): https://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm#:~:text=Comparing different datatypes

Another thing to look at is: https://www.autoitscript.com/autoit3/docs/functions/VarGetType.htm

Maybe not entirely useful here, but it's along the same lines and is important to keep in mind.

We ought not to misbehave, but we should look as though we could.

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