BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 8:36 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: To create my own library file
PostPosted: Wed Aug 10, 2011 4:22 am 
Offline
New User

Joined: Wed Aug 10, 2011 4:12 am
Posts: 3
Basic micro,

I purchased this module Basic Atom Pro ONE and I wanted to know if there is any possibility to create my own library file like I do in C++(#include<myfile.h>).
I want to create a library file according to my application say a program to read certain inputs so that i can write my command to read those inputs directly instead initializing the inputs and change direction settings. I want to make it simple for me by creating an initialization command in my library so it goes and initializes for settings I want and my instruction looks simple.
Is it possible to create my own library files?
Or
I have to use the given instructions only?

I hope you understood what I wanted to say. Please help me.

Thank you,

Macjan


Top
 Profile  
 
 Post subject: Re: To create my own library file
PostPosted: Wed Aug 10, 2011 4:29 am 
Offline
New User

Joined: Wed Aug 10, 2011 4:12 am
Posts: 3
Basic Micro,

The software I'm using is Basic Micro Studio. I forgot to mention above.

Thank you,

Macjan


Top
 Profile  
 
 Post subject: Re: To create my own library file
PostPosted: Wed Aug 10, 2011 6:43 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 528
My assumption from your description is that you are doing this in basic?

If so you have a couple of ways to approach it. You can include a file:
#include "foo.bas"
This is described on page 218 of the current syntax manual.

You can create projects. In the IDE it is Menu item (File\New Project). This creates a directory with one file in it. You then can create/add other files to the project. Note: projects more or less work like they are a simple file that includes the files listed in the project in the order they are listed in the project.

But unlike C there is no scoping of variables or definitions. That is once defined it is available from the point on in the file and subsequent files. If you use a variable in one file and use it again in another file, you can not define it twice... (been bit a few times here). So sometimes for library files that have some common functions that I wish to include in several projects, I end up using some naming convention to avoid these issues.

Good Luck.
Kurt

P.S. - You can also create c/c++ projects. You can create libraries to include into your projects, but it is not clean and you need to edit some files and create the actual library outside of the IDE (I use makefile and command prompt)


Top
 Profile  
 
 Post subject: Re: To create my own library file
PostPosted: Thu Aug 11, 2011 1:50 am 
Offline
New User

Joined: Wed Aug 10, 2011 4:12 am
Posts: 3
Kurt,

Thank you for your reply. I did not notice the include files notes in that syntax manual. I tried as what you said and it is working fine.
Only problem I found was that when I wrote #include"myfile.bas"before writing any of my code It would execute that file instead my actual code.
So i tried putting this include file at the end instead and there was no issues of any sort.

WRONG:
#include"myfile.bas"

main
/*do programs*/
gosub myfile
go main

CORRECT:

main
/*do programs*/
gosub myfile
go main

#include"myfile.bas"


Thank you once again,

Macjan


Top
 Profile  
 
 Post subject: Re: To create my own library file
PostPosted: Thu Aug 11, 2011 5:58 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 528
Yep, the lines in the included file are executed as if they were inline...

The other option would have been something like:

goto Main
#include "xyz"
Main:


Top
 Profile  
 
 Post subject: beton
PostPosted: Fri Aug 12, 2011 9:40 pm 
Offline
New User

Joined: Fri Aug 12, 2011 9:32 pm
Posts: 1
Location: Mongolia
yeap Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO