September 25, 2022, 11:12:36 PM

News:

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


5a. Adding code

Started by LarryMc, October 14, 2014, 12:06:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

The easiest source file to code is the _todo.iwb file.
Add this single line to the file:
$END
Now you can type anything you want after that line without having to add remarks to keep it from generating errors.

When the compiler encounters that directive it ignores what follows it in a source file.

With just that directive all keywords will still be colored by the editor.  If those colors bother you everything can be put between
/*      ...   


*/

and everything will be the commented color.

----------------------------------------

the next file we will address is the initial code structure for the globals.iwb file
There are two ways to set up this file .
One places all the structures, constants, external declarations, and imports directly in the file along with the global definitions.  The other way places all of those in their own inc files and $INCLUDE'd into the globals.iwb with the global declarations.  For now I won't use the extra inc files.

The first thing I add to the globals.iwb file is
AUTODEFINE "OFF" /* I always use this - personal preference */
AUTODEFINE "OFF" - keeps me from inadvertently assigning the wrong type of value to a variable.

Next I add
$include "windowssdk.inc"  /* I always use this - personal preference */

$INCLUDE "windowssdk.inc" - saves me a lot of time in not having to look up declarations for system functions, except in rare cases.

Next I add any other inc files I might need such as
'$include "Commctrl.inc"
'$include "ctl.inc"


Next is the 'structures' section.  Entries here can be added to a 'struct.inc' file and then the
$INCLUDE "struct.inc"
can be used in the globals.iwb file instead of adding the structure entries directly to the globals.iwb file
For this tutorial the 'struct.inc' file will not be used.
So the entry will look like this:
/******* structure definitions ******************************************/
'$INCLUDE "struct.inc"

/******* end of structure definitions ***********************************/


The paragraph above that describes structures applies also to constants and externals.
So their entries look like
/******* constants definitions ******************************************/
'$INCLUDE "const.inc"

/******* end of constants definitions ***********************************/

/******* extern definitions ******************************************/
'$INCLUDE "extern.inc"

/******* end of extern definitions ***********************************/


And finally we add
projectglobal "on"

projectglobal "off"

Between the two commands is where we will add any variables we might need to access from any source file in our project

Now that we have the basic code structure complete in the globals.iwb file we are ready to the next step.
In the utils.iwb, mainsetup.iwb, and dialog_1.iwb files add this
$include "globals.iwb" as the first line in each file.

In the main.iwb file add the same line after the
$MAIN
directive.

We are now ready to start writing the actual code for our application.

This completes 5a. Adding code
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library