RE: Conditional/dynamic include
- Posted by David Davis <gdavis at hypercon.net> Sep 09, 2003
- 381 views
Very Nice, A good way of building an app that will only be used on one platform, but still not as portable as I'd like since it cal only be changed at either the point of distribution, or binding. I believe Conditional Includes have been around nearly since the time of K&R and have been relativley bug-free since I began back in the stone age. :) It would be handy to send out an App with something like Dosinc.e and Wininc.e so the end user could use either platform or both if they choose Igor Kachan wrote: > > > Hello David, > > Try please, is the code below too bad ? > > -- code > global procedure prepare_libs(sequence name, sequence list_libs) > integer fn > fn=open(name, "wb") > puts(fn, list_libs[platform()]) > close(fn) > end procedure > > sequence conditional_libs > conditional_libs ={ > -------------------dos > "include c.e\n" & > "include d.e\n" & > "include e.e\n" , > -------------------win > "include b.e\n" & > "include f.e\n" & > "include g.e\n" , > -------------------lin > "include a.e\n" & > "include h.e\n" & > "include i.e\n" } > > prepare_libs("con_libs.e", conditional_libs) > include con_libs.e > -- end of code > > See please, you can make the *conditional* > including without any if & elsif & else conditions. > > More complicated interpreter is more buggy interpreter. > And just this current 'simple' interpreter is a great tool, > I think. > > The code above works with translator and binder too. > > Just delete old con_libs.e from the current directory then run code > with ex.exe interpreter. > You'll have new con_libs.e for the DOS platform in the current > directory. Then run bind code. You'll have .exe for DOS with that > new con_libs.e included. > bind.bat must run ex.exe, not exw.exe. > Then run ec with code, then run emake.bat and you'll have > compiled .exe for DOS. > > Then delete con_libs.e for DOS from the current directory and run code > with exw.exe interpreter. > You'll have new con_libs.e for the WIN platform in the current > directory. > Then run bindw code. You'll have .exe for WIN with that new con_libs.e > included. > bindw.bat must run exw.exe as it runs. > Then run ecw with code, then run emake.bat and you'll have compiled .exe > for WIN. > So, the trick is to DELETE the bad con_libs.e and CREATE new good one > with needed interpreter before binding or translation for the needed > platform. > > Regards, > Igor Kachan > kinz at peterlink.ru > >