(again) [clean-list] why it doesn't work ... ?
Carlos Aya
carlosayam at yahoo.com.au
Sat May 10 06:06:34 MEST 2008
Hello,
Sorry, didn't imagine it was going to strip out my message...
...
Message: 2
Date: Thu, 8 May 2008 22:51:28 -0700 (PDT)
From: Carlos Aya <carlosayam at yahoo.com.au>
Subject: [clean-list] why it doesn't work ... ?
To: clean list <clean-list at science.ru.nl>
Message-ID: <367902.35557.qm at web52506.mail.re2.yahoo.com>
Content-Type: text/plain; charset="utf-8"
...
So, again, here it is...
My first serious attempt to get into functional thinking...
I already have something to parse a CSV line, using the Parsers
library. That works. But when I wanted to plug-in this into reading a
CSV file and doing something to it, got stuck. So, this is my simple
read from fin (file-Input) to fout (file-Output) - I plan to plug a f
:: String -> String in processFile to manipulate the line as I read
the input file. But before getting into that, at least I should be able
to print the file to stdout, shouldn't I? However, I run it and it
doesn't do anything. I believe is an issue with laziness...
I put the input and output files as arguments and used let-before to read the line and pass it
to the output file in the body. I used #! later, thinking that laziness
was in my way, but still doesn't work.
Any help appreciated.
Regards
Carlos
BTW, I'm using the magic set_console_flag J.V.G sent few days ago ;-)
I tried all console options in 'Project options'...
I read the code of copyfile.icl (small examples) but couldn't
follow it. And it doesn't use the # or #!, so I think my question is
still standing...
here the code... (sorry, C&P messed up indentation...)
----------------------------------------------------------------------------------------------
module copy1
import StdOverloaded
import StdFile
import ArgEnv
import StdClass
import StdArray
import StdInt
import StdString
from StdMisc import abort
processFile :: *File *File -> (*File, *File)
processFile fin fout
#! (end, fin) = fend fin
| end = (fin, fout)
#! (line, fin) = freadline fin
#! fout = fwrites line fout
| otherwise = processFile fin fout
set_console_flag :: Int;
set_console_flag = code {
pushL _console_flag
push_b_a 0
pop_b 1
push_node EMPTY 0
push_a_b 0
pop_a 1
}
Start :: *World -> *World
Start world
| set_console_flag==0 = abort "cannot console"
# args = getCommandLine
| (size args) <> 2 = abort "use 1 argument"
# (ok, fin, world) = fopen args.[1] FReadText world
| not ok = abort ("cannot open" +++ args.[1])
# (fout, world) = stdio world
# (fin, fout) = processFile fin fout
# (ok, world) = fclose fin world
| not ok = abort ("error closing " +++ args.[1])
| otherwise = world
----------------------------------------------------------------------------------------------
Get the name you always wanted with the new y7mail email address.
www.yahoo7.com.au/y7mail
More information about the clean-list
mailing list