Jonathan,

The following code should work on Windows as a work around the problem:

procedure main(arglist)
  ...
  OPEN :=: open   # hook open call 
  ...
end 


procedure OPEN(x[])
x[1] := map(x[1],"/","\\")
return OPEN!x
end



David

----- Original Message ----
From: Clinton Jeffery <[EMAIL PROTECTED]>
To: Jonathan Kaye <[EMAIL PROTECTED]>
Cc: unicon-group@lists.sourceforge.net
Sent: Thursday, January 17, 2008 3:49:55 PM
Subject: Re: [Unicon-group] porting to Windows?

Unfortunately, when Icon and Unicon call open() and related functions, we
turn things over to C runtime system functions, which usually turn things
over to .DLL files which are shipped with the system...

Which means, the same .exe can and does behave differently on different

versions of Windows. The safest thing to do on Windows is to use \ which
in string constants looks like "\\" and works on all DOS-based OSes such
as Windows.  Unfortunately this means code that is to be portable ends up

with $ifdef's or if-then's. It might be reasonable to propose that open() 
automap
/ into \ BEFORE calling the C fopen() or whatever, since we can't trust the
library function to do it. What are the risks or downsides of doing this? Should

we automap \ into / on UNIX systems? :-)

Clint

On Jan 17, 2008 10:53 AM, Jonathan Kaye <[EMAIL PROTECTED]> wrote:

Jafar Al-Gharaibeh ha escrit el 17/01/08 19:17:
> I have tested the following program under Windows XP Home
>
> procedure main()
>
>    fname := "a\\data.txt"

>    fin := open(fname) | stop("can't open ", fname)
>    s:=reads(fin, 20)
>    write(s)
>    read()
>
> end
>
>  I tested the program with  "a\\data.txt"  ,   "a/data.txt"  and even

> "a//data.txt"
>
> all of them worked just fine and I got the expected result.
>
> I assume that "\\" and "/"  are interchangeable and work correctly
> under Windows.

>
> Thanks,
> Jafar.
>

Hi Jafar,
    Thanks so much. You are a gentleman and a scholar. This is what I
thought. The bad news is now I have no clue as to why some Windows users
can't open the data file. My code looks like this:

#    Setup i/o
    datadir := "Data/"
    outdir := "Output/"
    resp := "y"
    while resp == "y" do {
    writes("Specify page to proof: ")
    flnm := read()

    infile := open(datadir || flnm || ".txt") | stop("can't open data
file: ", chdir(), "/", datadir, flnm, ".txt")
    outfile := open((outdir || flnm || ".out"), "w") | stop("can't open

output file: ", chdir(), "/", outdir, flnm, ".out")

Could this be a Vista issue?
Anyway thanks again for your help.
Cheers,

Jonathan


--
Jonathan Kaye
Sip Phone: [EMAIL PROTECTED]
Registered Linux user #445917 at http://counter.li.org/




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/unicon-group








-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to