[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: Include problem



On Mon, Nov 19, 2001 at 11:26:39AM +0100, Alvise Belotti wrote:
> Hi all,
> I hope my bad english will be understandable.
> 
> I have a problem with include files. 
> 
> Basically I want include a file -if it exist- otherwise include a
> default file
> #include file.inc (if it exist) else include default.inc
> (the name of the file to be included has to be defined run-time)
> 
> >From wml_p1_ipp
> 
> $(name:-string)
> `Use Default String': The standard interpolation with
> a default value.
> 
>  if (exists(name))
>      expandto(valueof(name))
>  else
>      expandto(string)
> But
> 
> #include "$($(WML_SRC_BASENAME).inc:-default.inc)"
> 
> include default.inc all the time (also if $(WML_SRC_BASENAME).inc
> exist)
> It seems $(WML_SRC_BASENAME).inc inside $(name:-string) will be expanded 
> to nothing.
> 
> what i am doing wrong, here?

Hi Alvise,

here is how wml_p1_ipp works with your example, assuming input file
is `foo.wml':
  0: #include "$($(WML_SRC_BASENAME).inc:-default.inc)"
  1: #include "$(foo.inc:-default.inc)"
  2: #include "default.inc"
  3: file default.inc included

Step 1->2 is done this way because the foo.inc _variable_ (and not file)
is not defined.

The only solution to your problem is to pass filename via a variable to
your file.

A smarter solution would be to add a parameter to the #include scheme to
prevent wml_p1_ipp from aborting, then define a variable in this file
and conditionnally include default.inc if this variable is not set.
Example:
   #include "foo.inc" IPP_NOABORT
   $(HAVE_FOO_INC:+# )$(HAVE_FOO_INC:*#)include "default.inc"
and add $(HAVE_FOO_INC=1) at top of foo.inc.
I will implement the IPP_NOABORT parameter soon, sounds like a good idea.

-- 
Denis Barbier
WML Maintainer
______________________________________________________________________
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com