[Gambas-user] Bug / changed behaviour of Input

Emil Lenngren emil.lenngren at ...626...
Wed Mar 14 15:59:43 CET 2012


Input never returns something with spaces in it. It works about the same
way as scanf("%s", ...), scanf("%d", ...). It splits up the input on white
spaces.

I think Input is kind of wierd when it uses Val.
If I write

Dim s As String
Input s
Print s

Then I might expect that I always get the string raw.
Now I get this:
"3-2" -> "03/02/2012"
"3,2" -> "3.2"
"True" -> "T"
"False" -> ""
"Yeah" -> "Yeah"

Since you probably know what kind of data that is to be read (instead of
Input guesses depending of the input string), it would be better to have
some syntax like "s = Input As String", "s = Input As Integer" like the
Read statement, but that it parses the string instead of just taking the
binary bytes. Throw an error if the string could not be parsed.

This parsing might be different from normal string conversion (just like
Val). For example, input "False" really returns False and not True if you
wanted a boolean...

What do you think?

/Emil


2012/3/14 Jussi Lahtinen <jussi.lahtinen at ...626...>

> Wait... How input determines how much is read?
>
> To read all what is written with this;
>
>  hFile = Open "/tmp/testingtesting/Test.txt" For Output Create
>  Print #hFile, "Test1"
>   Print #hFile, 123
>  Print #hFile, CDate(2484515)
>  Print #hFile, " 1-2/3/4/5_6*7-8+9"
>  Close hFile
>
>
> I need to call input six times;
>
>  sStr = ""
>  sTest = ""
>   hFile = Open "/tmp/testingtesting/Test.txt" For Input
>     For ii = 1 To 6
>      Input #hFile, sStr
>      sTest &= sStr
>    Next
>  Close hFile
>
> And still one white space is missing, "1-2/3/4/5_6*7-8+9" instead of "
> 1-2/3/4/5_6*7-8+9".
>
> I'm not sure input is right method for reading such data... I always use
> command Read.
> Is this correct?
>
> Jussi
>
>
>
>
>
>
>
>
>
> On Wed, Mar 14, 2012 at 14:59, Jussi Lahtinen <jussi.lahtinen at ...626...
> >wrote:
>
> > Yes, it works now.
> >
> > Jussi
> >
> >
> >
> >
> > 2012/3/14 Benoît Minisini <gambas at ...1...>
> >
> >> Le 14/03/2012 13:12, Jussi Lahtinen a écrit :
> >> >    hFile = Open "/tmp/testingtesting/Test.txt" For Output Create
> >> >    Print #hFile, "Test1"
> >> >    Close hFile
> >> >
> >> >    sStr = ""
> >> >    hFile = Open "/tmp/testingtesting/Test.txt" For Input
> >> >    Input #hFile, sStr
> >> >    Close hFile
> >> >
> >> >
> >> >> From revision 4549, sStr remains null.
> >> >
> >> >
> >> > Jussi
> >> >
> >>
> >> Is it better with revision #4552?
> >>
> >> --
> >> Benoît Minisini
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> Virtualization & Cloud Management Using Capacity Planning
> >> Cloud computing makes use of virtualization - but cloud computing
> >> also focuses on allowing computing to be delivered as a service.
> >> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> >> _______________________________________________
> >> Gambas-user mailing list
> >> Gambas-user at lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>
> >
> >
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>



More information about the User mailing list