ASP preproccessor instructions?

  • ProgramMax
  • Newbie
  • Newbie
  • ProgramMax
  • Posts: 12

Post 3+ Months Ago

I am using a lot of server side includes in my website. Say for example one of my includes also includes adovbs.inc. adovbs.inc then defines several values.

So if I have index.asp and it has two includes, both of wich include adovbs.inc, I get an error claiming I am redefining values. This makes sense...it was defined in the first include to adovbs.inc and will be redefined upon the second.

Anyway, in C++ I can use a simple #ifndef filename #define filename //contents #endif. That will let me include all day long and never worry about redefining. Is there something similar in ASP? Or is there anything I can do to allow similar functionality?

Without that I've been reduced to writing very coupled, hard-coded, sloppy, no-standards code. It has become frustraiting.

Thanks!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

What I have found works really nicely is to create an include file that contains the utilits and constants (adovbs.inc). Then I just make sure I include the one file and all the pages will have the same variables.

As far as I know ASP doesn't support checking for defined variables. It really is a bastardized language with very little support.

I have noticed that ASP is very cumbersome so the lack of support for checking that type of thing doesn't surprise.
  • ProgramMax
  • Newbie
  • Newbie
  • ProgramMax
  • Posts: 12

Post 3+ Months Ago

I see what you mean and in a way that is what I'm doing now, but it is very lame.

IE every .ASP includes adovbs.inc. Then all my other .inc files *hope* that adovbs was indeed included correctly. It I mess up the include order the code breaks. Also if there is a simple page that doesn't have any .inc files included and doesn't interact with the database, I shouldn't be including adovbs.inc.

I suppose that is the best solution though...I haven't found much else.

Thanks for your help!
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

one other thing - MAJOR SECURITY FLAW!

don't call your include files .inc unless you have set the server to process .inc files the same way as .asp files. Rather call them like adovbs.inc.asp.

If someone guesses the name of your include file and enters it in the url the will see the unparsed scripts.
  • ProgramMax
  • Newbie
  • Newbie
  • ProgramMax
  • Posts: 12

Post 3+ Months Ago

Oh good point. Thank you!
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

Cool
  • ProgramMax
  • Newbie
  • Newbie
  • ProgramMax
  • Posts: 12

Post 3+ Months Ago

I just found out that server side includes also offer some sort of if statement. It looks like I can compare values and the such but for me to have some sort of if/endif block that only executes once, I also need some way of setting the variable.

Just wondering if anyone can confirm or deny that SSI if statements could allow one-time includes.

Thanks!

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: demonmaestro, VanessaGilbert and 138 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.