Read from a file

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Read from a file

Casale, Vincent
I'm trying to read from a file and print out the 7th word in the file using
NetRexx 1.148. But when I compile
this program I get

ERROR: The Method 'readLine()' cannot be found in class 'netrexx.lang.Rexx'
or a superclass

Can anybody help?

/* file\urlcntr.nrx */

parse arg fname

infile = FileReader(fname)
buffer = BufferedReader(infile)

loop forever
  textline = source.readLine()
  IF textline = null THEN leave
  ELSE say textline.word(7)
end

Vincent Casale
S390 Web Engineering Group, Mgr.
201-524-2034
[hidden email]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: Read from a file

Vesa Erla
Hi Vincent,
use buffer.readLine() instead of source.readLine()
-vesa

>parse arg fname
>
>infile = FileReader(fname)
>buffer = BufferedReader(infile)
>
>loop forever
>  textline = source.readLine()    
>  IF textline = null THEN leave
>  ELSE say textline.word(7)
>end


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: Read from a file

Charles F. Simons
Vincent,

There's another problem hiding around the corner after you make the substitution
suggested by Vesa.

buffer.readLine returns a java String or null.  Later you want to use the .word
method which needs to operate on a Rexx string.

I changed code to:
--------------------
parse arg fname

infile = FileReader(fname)
buffer = BufferedReader(infile)

loop forever
  textline = buffer.readLine()   -- textline is a java String
  IF textline = null THEN leave
  rexxVariable = rexx(textline)  -- convert java String to a Rexx object
  say rexxVariable.word(7)
end
-----------------

Sincerely,

Charles Simons



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: Read from a file

Charles F. Simons
In reply to this post by Casale, Vincent
Satgura,

Its true that for...

x = 12.5   or  y = 'these words'

that both x and y are of type Rexx.  This is because 12.5 and 'these words' are
considered as being of type Rexx.  Try the following one line program and you'll see
what I mean...

say 'one two three four'.word(2)

it will output 'two' to the standard output.  The .readLine() method is not a
netrexx method it is a java method from I believe the BufferedReader class.  It
returns a Java String.  In order to use the .word() method of the Rexx class you
must convert the Java String to type Rexx.

I know thats more than anyone wanted to hear, sorry for taking up your time.

-- Charles Simons



Satguru Srivastava wrote:

> Charles,
> I thought if one doesnot declare a variable to be of a particular
> type it's type would default to Rexx.
>
> Wouldn't textline default to type Rexx ?
>
> Thanks
> Sat
>
> >>> "Charles F. Simons" <[hidden email]> 06/04 1:48 PM >>>
> Vincent,
>
> There's another problem hiding around the corner after you make the substitution
> suggested by Vesa.
>
> buffer.readLine returns a java String or null.  Later you want to use the .word
> method which needs to operate on a Rexx string.
>
> I changed code to:
> --------------------
> parse arg fname
>
> infile = FileReader(fname)
> buffer = BufferedReader(infile)
>
> loop forever
>   textline = buffer.readLine()   -- textline is a java String
>   IF textline = null THEN leave
>   rexxVariable = rexx(textline)  -- convert java String to a Rexx object
>   say rexxVariable.word(7)
> end
> -----------------
>
> Sincerely,
>
> Charles Simons
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
> [hidden email]
> with the following message in the body of the note
> unsubscribe ibm-netrexx <e-mail address>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

JDK 118 for OS/2 up for public testing...

mcbrides
I'm running the JDK118 from IBM with NetRexx 1.148 and all is well. This is a
REAL treat getting the JavaComm direct from IBM for a change! Thanks gals/guys.

Signed,
        one happy camper...


--

/--------------------\
| Jerry McBride      |
| [hidden email] |
\--------------------/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>