Page Index Toggle Pages: [1] 2 3  Send Topic Send Topic Print Print
Very Hot Topic (More than 25 Replies) #include files (Read 3636 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
#include files
Jul 11th, 2007 at 7:32pm
Print Post Print Post  
I'd like to start splitting out my functions and subroutines into files which I can use with #include, but I have a bit of confusion.

Is there a file naming convention I should follow?  Any disallowed characters?  Should I stick with .sbas?

Should I place the #include statement in the programming exactly where the code I'm removing once went?

Where does the .sbas file go?  I think it belongs in the server's working directory, but I want to be sure.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: #include files
Reply #1 - Jul 12th, 2007 at 4:25pm
Print Post Print Post  
Wow, have I messed up my application.  #include = bad thing.  I need some aspirin, a stiff drink, and a nap.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: #include files
Reply #2 - Jul 12th, 2007 at 4:35pm
Print Post Print Post  
#include = Very powerful thing but it is not a bad thing at all.

How have you mesed up your application?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: #include files
Reply #3 - Jul 12th, 2007 at 6:10pm
Print Post Print Post  
It's a long, complicated tale, full of terror and woe.  Basically, I have no idea where to put the files (the documentation is no help with this question; it mentions building a library of code but doesn't say where to put it, or offer any guidance on naming conventions), so I stuck with naming them like sbasic_include.sbas, with underscores and a .sbas extension, and then tried putting them in different places, in this folder, in that.  Eventually I hard coded paths into my programming (for example
Code
Select All
#include "F:\Sesame\Includes\SUBROUTINE_CustomerDiscount_Include.sbas" 


which seemed to work fine from a workstation client but crashed the app with sbasic errors when a client was run run on the server, of course, because the server doesn't know where F is.

I tried changing my "Start In" folders, did this and that, and so on.  Finally after the seventh or eighth db lockup (requiring unloading at the server before I could unlock; the dsr locked up a couple of times as well, though that didn't need unloading, of course) I decided to go back to the app that worked 2 days ago, whose only #include is sbasic_include.sbas, which I have littered everywhere

I think I still have my Start In settings messed up.  All my lookups and @Inserts stopped working for a while.  My current personal workstation client Start In folder is F:\Sesame\Miara and on the server (for my client on the server) it's C:\Sesame\Miara, and this seems to be working.  However, my 3 other workstation clients, which only access Employee.db (which has no lookups) start in C:\Sesame, and they seem to be working OK too.

After my headache goes away I think I'll try removing sbasic_include.sbas from all the folders that it's in, then putting it back into one folder at a time, testing the app each time to find out which one works.  I think if I can do that I'll know where to put the .sbas files I've made from my functions and subroutines.

Meanwhile, while all this was going on our Verizon FIOS was down and they couldn't give me any idea what the problem was or when it would be fixed, so not only did I have no way of asking for help here I also had to put up with calls from everyone in my company about that "When is the internet going to be up?  I have to send payroll withholding figures to the Federal Government/look up a phone number for an important client/send my mother an email asking her if the cat is still wheezing/surf the web looking for naughty pictures of librarians, etc."  Sigh.  I need a vacation.

OK.  Rant over.  I'll bet you're sorry you asked, huh?  Wink
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: #include files
Reply #4 - Jul 12th, 2007 at 6:32pm
Print Post Print Post  
Scott,

1. Unless you want to use your subroutines on multiple layouts, there is no reason to put them in include files.

2. The file naming conventions are the same as for all the other file commands, such as @Insert.

If you just put the filename in quotes, Sesame will look for it in the current working directory.
#include "my_include_file.txt"

If you use a relative path, Sesame will look relative to the current working directory. To use your include files in a subdirectory of your working directory:
#include "Includes\my_include_file.txt"

If you use an absolute path, Sesame will look where you specify.
#include "C:\SesameIncludes\my_include_file.txt"

3. SBasic runs on the client. Your include files need to be on the client, or on a path the client can see.

Hope that helps!
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: #include files
Reply #5 - Jul 12th, 2007 at 6:58pm
Print Post Print Post  
Quote:
1. Unless you want to use your subroutines on multiple layouts, there is no reason to put them in include files.

Ah.  OK.  I was under the impression that removing them from the main mass of code would speed up compile time, which is a concern I have especially for my Workorder and Invoice programs, which are heavy.
Quote:
2. The file naming conventions are the same as for all the other file commands, such as @Insert.

[Thanks.  I think I'll stick with naming them .sbas, so they'll jump out at me.  I use .txt files for my @Inserts.
Quote:
If you just put the filename in quotes, Sesame will look for it in the current working directory.
#include "my_include_file.txt"

If you use a relative path, Sesame will look relative to the current working directory. To use your include files in a subdirectory of your working directory:
#include "Includes\my_include_file.txt"

If you use an absolute path, Sesame will look where you specify. 
#include "C:\SesameIncludes\my_include_file.txt"

3. SBasic runs on the client. Your include files need to be on the client, or on a path the client can see.

Hmmm.  This gives me much to think about.  I would like them to reside on the server (which all clients can see as F, because that will give me just a single place to work with them.  Updating all clients could be a nuisance.  I'll miss one, or be called away when updating them, or some darn thing will happen, who knows around here.  But maybe if I set each client to have a network shared Include folder, map a drive to each one, store all my edited files on my workstation, and then write a batch file to copy them to each client drive.   Hmmm.  This will require more coffee.

I think the problem is that I'm still a bit shaky on the "working directory" concept.  Is it the same as the "Start In"?  Or is it more ethereal, maybe just being related to the particular app that's open?  One of the problems I had earlier today, while manipulating Start In settings, is that suddenly Sesame saw the db's on my server as just residing in "C:\Sesame\Miara".  That is to say, Sesame no longer saw a valid F drive, and when I tried to open a file from F:\Sesame\Miara  I got an "unwritable" error.  Once I set my workstation Start In folder to F:\Sesame\Miara this problem disappeared, but I'm pretty sure by doing that I'm going against some instruction that Ray gave me at the conference (not 100% sure because I can't find my darn notes) and, as I said earlier, my other workstations (which have their Start In setting as C:\Sesame) seem to be working fine with the app they access (although that one has no lookups, so it may be broken and I just don't know it.)

Quote:
Hope that helps!

It certainly does, thanks!
  

**
Captain Infinity
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: #include files
Reply #6 - Jul 12th, 2007 at 7:33pm
Print Post Print Post  
Infinity wrote on Jul 12th, 2007 at 6:58pm:
I would like them to reside on the server (which all clients can see as F, because that will give me just a single place to work with them.



As Erika said - so long as the clients can get to them, that will be fine.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: #include files
Reply #7 - Jul 12th, 2007 at 8:02pm
Print Post Print Post  
Thanks Mark.  I'm still a bit confuzzled on how to point to them, though.  My problem is confusion with "working directory" and "Start In".

Say I do this:
The server, as referenced by all my workstations, is drive F.

The Sesame executable resides on each client and the workstation in C:\Sesame\Program.

The applications are on the server in Sesame\Miara  This is referenced from each workstation as F:\Sesame\Miara and at the server as C:\Sesame\Miara.

I can't hard code "#Include "F:\anyfolder\IncludeFile.sbas"" because the app would fail when run at the server, which knows no F drive.

Now, looking at what Hammer said earlier, maybe I should:
1. Set each workstation's Start In directory as F:\Sesame\Miara
2. Set the server's client to Start In C:\Sesame\Miara
3. Put all my Includes on the server in Sesame\Miara\Includes
4. Hard code my #Include statement as #include "Includes\my_include_file.sbas"

I think this might work.  Is anything jumping out at you that I should try differently?  If I do this, will the Sesame.ini file in the server's Sesame\Miara folder override the .ini files on the individual workstations?  If my understanding of the Start In directory is wrong, then perhaps step 1 is unnecessary, and each workstation should Start In C:\Sesame, which is where their .ini files currently are.

I'll bet Ray is fuming at me.  He's tried to explain this to me a number of times, and so far I've understood it.  Today, however, #Include files have thrown me for a loop.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: #include files
Reply #8 - Jul 12th, 2007 at 8:17pm
Print Post Print Post  
Working Directory and Start in refer to the same thing.

You will want the clients Start In to be C:\Sesame this way each client can have their own INI file and will have thier own Sesame log.

You can create an F: drive on the Server system that is the C: drive on the Server system. Just map it the same as you would from a client computer. That is going to be the easiest way for you do what you need to do.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: #include files
Reply #9 - Jul 12th, 2007 at 9:01pm
Print Post Print Post  
Hi Ray!

I made a subfolder on my server, Sesame\Miara\Includes, and moved sbasic_include.sbas there.  I made sure that sbasic_include.sbas does not exist on my C drive in any place Sesame might try to find it, nor do any of my apps.   I then hard coded my include statement as
Code
Select All
#include "Includes\sbasic_include.sbas" 



If I set the Start In directory to be C:\Sesame, I can tell from the look of the window that it is using the sesame.ini file in my C:\Sesame folder.  However, the apps presented to me with "Open" appear to be in C:\Sesame\Miara (which does not exist on my workstation).  When I open MIARA.db, the bar at the top of the application screen tells me I have opened C:\Sesame\Miara\MIARA.db (though it has to be F:\Sesame\Miara\MIARA.db because that folder\app is not on my C drive).  Once the app is opened all goes well until I open a form, at which time my app fails with a "some or all programming has failed to compile" error.  When I acknowledge this I get a "runtime SBASIC error has occurred, please repair before continuing".

If I then change my Sesame program icon to have a Start In directory of F:\Sesame\Miara, once again I can tell from the appearance that it is using the sesame.ini file in F:\Sesame\Miara.  So far so good.  However, the apps are still presented to me as existing on C:\Sesame\Miara.  I can open them and the forms work perfectly, no more errors.  But I can still see no F, and if I try to navigate to C all I get is the server's C drive.  All my rootdirs.ini files include [DRIVES], by the way.

Weird.  I'll bash away at it some more tomorrow, and try mapping the server's C to F, as you suggested.  My thanks again to everyone who helped me today.
  

**
Captain Infinity
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: #include files
Reply #10 - Jul 13th, 2007 at 5:27am
Print Post Print Post  
Infinity wrote on Jul 12th, 2007 at 6:58pm:
I was under the impression that removing them from the main mass of code would speed up compile time

I have found that it actually may slow down compile time just a bit, because Sesame has to go out and read the drive again for each .sbas file.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: #include files
Reply #11 - Jul 13th, 2007 at 1:10pm
Print Post Print Post  
Infinity wrote on Jul 12th, 2007 at 9:01pm:
However, the apps presented to me with "Open" appear to be in C:\Sesame\Miara (which does not exist on my workstation).  When I open MIARA.db, the bar at the top of the application screen tells me I have opened C:\Sesame\Miara\MIARA.db (though it has to be F:\Sesame\Miara\MIARA.db because that folder\app is not on my C drive). 


Sesame is true Client Server. That C Drive that you see is the Server's C drive, not the Client's C drive.

Quote:
If I then change my Sesame program icon to have a Start In directory of F:\Sesame\Miara, once again I can tell from the appearance that it is using the sesame.ini file in F:\Sesame\Miara.  So far so good.  However, the apps are still presented to me as existing on C:\Sesame\Miara. 


You want the Client Start In to be C:\Sesame
You want your Target to be C:\Sesame\Program\sesame.exe -Client ServerName
You will want your include statement to be #include "F:\Sesame\Miara\Includes\sbasic_include.sbas"
You will need to map the C drive on the Server computer so that it is also the F drive on the Server computer.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: #include files
Reply #12 - Jul 13th, 2007 at 1:14pm
Print Post Print Post  
Quote:
I have found that it actually may slow down compile time just a bit, because Sesame has to go out and read the drive again for each .sbas file.


Yes it will slow the Compile time by a bit as it reads in the .sbas file. The main reason for include files is so that you just have to type one include statement and not copy and paste all the custom functions and subroutines that you have written.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: #include files
Reply #13 - Jul 13th, 2007 at 2:38pm
Print Post Print Post  
Quote:
You want the Client Start In to be C:\Sesame
You want your Target to be C:\Sesame\Program\sesame.exe -Client ServerName
You will want your include statement to be #include "F:\Sesame\Miara\Includes\sbasic_include.sbas" 
You will need to map the C drive on the Server computer so that it is also the F drive on the Server computer.


Thanks Ray!  I'll give it a try.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: #include files
Reply #14 - Jul 13th, 2007 at 2:45pm
Print Post Print Post  
Let me know if you have any questions.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 3 
Send Topic Send Topic Print Print