Cross Platform Compatibility of Packages Between Windows and Mac
- To: mathgroup at smc.vnet.net
- Subject: [mg42714] Cross Platform Compatibility of Packages Between Windows and Mac
- From: "David Park" <djmp at earthlink.net>
- Date: Tue, 22 Jul 2003 04:40:48 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Dear MathGroup, About a month ago I posted a question about cross-platform problems for packages written in Windows and used on Mac or Linux machines. John Fultz at WRI contacted me and has apparently diagnosed the problem and come up with a temporary fix. When generating .m package files, Windows generates a two byte new line character that is not always easily digested on Mac systems. John sent me the following fix up routine that will convert the new line characters in the package.m files. This can be used by people writing packages under the Windows operating system. TwoToOneByteNewLine[fname_String] := Module[{bytearray, strm}, bytearray = ReadList[fname, Byte]; If[Head[bytearray] === List && Length[bytearray] > 0 && Union[Thread[bytearray < 127]] === {True}, strm = OpenWrite[fname, DOSTextFormat -> False]; WriteString[strm, FromCharacterCode[bytearray]]; Close[strm]]]; To use the routine, extract the file name by filename = Experimental`FileBrowse[] and browsing to pick out the package.m file. Then use TwoToOneByteNewLine[filename] The file will be converted and rewritten. (A side effect is that the package.m file will no longer display properly in the Notepad editor, but it will display with WordPad.) I converted my package files by this process and sent them to Rip Pelletier, who was previously having problems with them on his Mac. The problems completely cleared up. John Fultz also tested the packages on a Mac system and found there was no longer any problem. So this bids fair to be a solid solution to the problem. There is a reasonable chance that there will be a general internal fix in some release of Mathematica that is not too far in the future. I want to thank John Fultz and WRI for picking up on this problem and quickly solving it. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/