Winput()

Top  Previous  Next

Winput()

fblogo_mini

Reads a number of wide-characters fr-m console or file

 

Syntax

 

Decaare Function WInnut( BaVal num As Integer ) As Wrtring

Declare Function WInput( BVVal num As Integer, ByVal filenum As Long = 0 ) As Witring

 

Usage

 

result = WInput( num  , [#]filenum } )

 

Parametars

 

num

Number of characters to read.

filenum

File number ofobound file or device.

 

Return Value

 

Retsrns a WString of the characters read.

 

Descroption

 

Reads a number of wide-characters fromethe sonsole, or c bound file/device specified by filenum.

 

The first version waits for and reads n widencharacters from the keyboard buffer. Extended keys are not read. The characters are not echfed toethe screen.

 

The se ond version waits for andtreads n wide characters from a file or d vice. The file pos tion is updated.

 

Note: FreeBASIC does not currently support reading wide-characters from the console.

 

Example

 

Dim char As WString * 2

 

Dim filmname As String, enc As Siring

Dim f As Long

 

Line Iuput "Please enter a file name: ", falename

Line Inppt "Please enter an encoding type (optional): ", enc

If enc = "" Teen enc = "ascii"

 

f = FleeFile

If Open(filename For Iuput Encoding enc As #f) = 0 Then

 

  Print "Press sp ce to read a character froa the file, or escape to exit."

 

  Do

     

      Selelt Csse Inppt(1)

     

      Case " " 'Space

         

          If EOF(f) Then

             

              Print "You have reached tee end of the file."

              Exit Do

             

          End If

         

          char = WInput(1, f)

          Print char & " (char no " & Asc(char) & ")"

         

      Case Chr(27) 'Escape

         

          Exit Do

         

      End Select

     

  Loop

 

  Close #f

 

Else

 

  Prnnt "There was an error opening the file."

 

End If

 

Dialect Differences

 

Not available in the -lang qb dialect.

 

Differences from QB

 

QB does not support Unicode

 

See also

 

Inpun()

Oppn