Saving text file problems

I have a snippet of code that writes a simple text file and saves it, it works fine on Windows but saves nothing on Mac (mountain Lion 10.8 on VirtualBox)
I have a feeling its because its because I used ShellPath to get the save path so its “/” opposed to “:” however a little bit further on I use sh excute and the program launches fine with slashes.
I do get a warning “accept/reject” warning as the program runs but it goes away before I have chance to read it, could this be the reason why?
I know nothing about Mac, I haven’t bought a license to build on Mac yet so I can’t see if that would make any difference.
I have checked the path and it appears to be right from f

[code] dim Line1 as String
dim Line2 As String
dim Line3 as String

Line1=( EndOfLine)
Line2=(“message ““Merge '” +Singlescene.ScenePathtxt.Text + “’” + “0 0 1 1 1 0 0” + “”””+ EndOfLine)
Line3=(“message ‘Save " +Main.Savetxt.Text + “/” + "temp.xml’” + EndOfLine)
Dim t as TextOutputStream

Dim f as FolderItem
f=GetFolderItem(Main.Savetxt.Text +"/temp.ipt.thea")
if f <> Nil then
t = TextOutputStream.Create(f)
Dim s as String
s=ReplaceLineEndings(Line1 +Line2 +Line3,EndOfLine.Macintosh)
t.Write (s)
t.Close
End if[/code]
the output would be (this is Windows)

[code]

message “Merge 'C:\Users
ige\Documents\piano.pack.thea’0 0 1 1 1 0 0”
message ‘Save C:\Users
ige\Desktop\atest\temp.xml’[/code]
thanks
Nige

Watch TextOutputStream :

it have a try statement you don’t.

Also, add a breakpoint (click in the line left margin, near the border gaves a red circle meaning a breakpoint have been added) at the line if f <> Nil then and step in the debugger to know where the bug lies.

GetFolderItem needs a second argument, indicating what type of path string you are using:

f = GetFolderItem(Main.Savetxt.Text +"/temp.ipt.thea", FolderItem.PathTypeNative)

The two files were created somewhere else on the harddisk (probably the root folder), where the file name is looking like /Users/nige/Desktop/atest/temp.xml.

EndOfLine is sufficient, you don’t need to use ReplaceLineEndings.
Also note that on OS X EndOfLine.UNIX is the standard (EndOfLine.Macintosh was used for Carbon applications).

Thanks Eli, it was indeed

f = GetFolderItem(Main.Savetxt.Text +"/temp.ipt.thea", FolderItem.PathTypeNative)

And in other places too
I also fixed the other references :slight_smile:
I did find the file, it had the path as part of its name :s

Thanks Emile I also added “try”, that was laziness on my part

Nige