Normal Topic #include "sbasic_include.sbas" (Read 432 times)
Mr Bear
Member
*
Offline


No personal text

Posts: 6
Joined: Dec 31st, 2003
#include "sbasic_include.sbas"
Mar 25th, 2011 at 1:18am
Print Post Print Post  
I see the precompilation construct: #include "sbasic_include.sbas" declared in some programming examples but not in others.

I see it used with code using XRESULTSET commands for example.

I am not sure what this declaration does and it what situations is it necessary. Any comments would be appreciated.

Thanks
Mr Bear
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: #include "sbasic_include.sbas"
Reply #1 - Mar 25th, 2011 at 2:47am
Print Post Print Post  
If you look in the file being included, you will see that it contains a number of defines. These defines can make your code more readable. It is never necessary, but using it will help you write more readable and maintainable code.

The XResultSet example looks like this:
vRSHandle = @XResultSetSearch("Customers.db", "Customers", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "")

In the line above, SEARCH_MODE_AND and SEARCH_SYNTAX_QA are defines provided by sbasic_include.sbas. If you remove the include, this line will not compile. The relevant defines in sbasic_include.sbas look like this:
#define      SEARCH_MODE_AND            0
#define      SEARCH_SYNTAX_QA            2


You can write the same line of code without needing the include file as follows:
vRSHandle = @XResultSetSearch("Customers.db", "Customers", 0, 2, "")

This will compile without the include but, as you can see, it's less clear.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged