I need to run a program (.p) on both client (Windows) and appserver (UNIX). We compile code on Windows environment. If I can condition the program to not run the block of code with Windows specific code (ex. .NET Framework reference, Win32 API) when running on the appserver, will it work?
Why would you not compile it separately for the two platforms? Perhaps using preprocessors to omit the Windows specific part?
Or, why not parse the program into two programs? One is run in both environments and the other is a persistent procedure or class or whatever that is only substantiated and accessed in a Windows environment.
Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice http://www.cintegrity.com
Just wondering if it is possible before I go about creating separate program files.
Yes, this is fine. R-code is not platform dependent. See KB for full explanation:
"6: R-code is NOT platform dependent" here:
(As a side, we also compile on Windows and ship the R-code to HP-UX-IA64. Those are about as different as two platforms can be. Thank goodness that HP-UX won't be a consideration very much longer...)
Insofar as running platform-specific code, you just check the result of OPSYS and do a different thing if you are on a non-windows platform. (Oddly the identifier for windows is "WIN32" even if your stuff is all 64 bit.)
WHEN "unix" THEN OS-COMMAND ls.
WHEN "win32" THEN OS-COMMAND dir.
OTHERWISE MESSAGE OPSYS "is an unsupported operating system".
I'd highly recommend reading this documentation if you do development that targets multiple platforms.
"Coding for Portability" here:
Hope this helps, David