June 16, 2024, 05:07:48 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Idiots guide to writing a simple project

Started by Andy, October 13, 2014, 01:52:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

I'm going square eyed trying to write even the simplest of projects, can anyone help please.

I understand the concept of a project, but everything I try just doesn't click at the moment.

If I wanted to have 2 source code files in a project, and one is obviously the "main" source, and the other a function or suborutine how do I do it?

Example:

The main source code -

Open a window or console

Call the second source code function to do "something" say calculate a number - X = 2 * 2
then have the main program print X and then end.

Sounds simple, that's how I'm feeling with this at the moment lol!

Can anyone show me a simple example please.

Thanks,
Andy.








Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

GWS

Hi Andy,

If you understand the concept of a project - you're way ahead of me .. ::)

I've never used a 'project' in all the years I've been programming.

In the little example you give, I'd write the 'main' code, and tuck the subroutine at the end of it.

Then it all is visible, editable, and compiles in one go. ;D

It may be that if you get a huge program, the compile time becomes noticeable - but even with my largest ever program, I've never noticed it.

Also I believe there are restrictions on what can go in project code .. like no globals for instance ..

So I wouldn't bother myself ..

Best wishes, :)

Graham

Tomorrow may be too late ..

LarryMc

The IWBasic 2.5 IDE contains 30,000 lines of code.  I can't imagine that much code stuck in one file.
As it is, when I recompile the entire program it takes a little over a minute.
However, after I do that one time, from then on I only have to recompile the file I have edited and then relink all to get the exe(which only takes a couple of seconds).
The only time I have to recompile all the source files is when I add something that is global.
Also, a project allows me to add all my images as resources to my exe.

Another plus with projects comes when you are building lib files which I've done a lot of.
1st I create a project with 2 source files. The $main file looks like a User's application that calls the lib functions.  The other is the source file(s) for the lib.
With this arrangement I can do all my testing without having to create a new lib file each time I make a change and copying the lib file to the IWBDev\libs folder.
When I'm ready to create the lib for release I create another project containing just the lib source files and compile it as a static lib.  It really speeds up the process.

@Andy - I post a little tutorial in the next 24 hours.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Quote from: GWS on October 13, 2014, 03:04:05 AM
... I believe there are restrictions on what can go in project code .. like no globals for instance ..

That is only true for CB and its components.
Not true in IWB. ;)
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

AdrianFox

Andy....

I found the most useful way for me of understanding the structure of a project and then using it as a template,  was by using Larry's IWB+ visual designer.  I don't know if you are familiar with it, but it generates all the needed code in project form with the globals, inc and main program file. If you create even the simplest of program outlines with this,  and then load it into the 'normal' IDE you can look at all the code that is generated in the Globals file, main iwb file and .inc file.   

You can follow this outline in setting up your own projects.  (The one 'drawback' is that you can't really make changes to the 'core' code in the IWB+ program itself as it is designed to generate particular code in particular places, so if you change it, the program will change it back.  But using the normal IDE you can of course change what you want.)

Adrian Fox