* *

Coding

Welcome, Guest. Please login or register.
Did you miss your activation email?
November 18, 2017, 12:38:51 PM

Login with username, password and session length

Menu

Members
Stats
  • Total Posts: 12175
  • Total Topics: 1736
  • Online Today: 52
  • Online Ever: 195
  • (February 11, 2014, 01:46:08 PM)
Users Online
Users: 0
Guests: 33
Total: 38
Baidu (5)

Author Topic: Global Variables in Projects  (Read 3384 times)

0 Members and 1 Guest are viewing this topic.

Offline PK

  • Newbie
  • *
  • Posts: 13
  • Bananas: 0
  • Gender: Male
  • I haven't set any personal text yet
Global Variables in Projects
« on: August 23, 2013, 07:13:19 PM »
Is it possible to pass values between routines using global variables?

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Global Variables in Projects
« Reply #1 on: August 23, 2013, 10:03:43 PM »
absolutely!
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Global Variables in Projects
« Reply #2 on: August 23, 2013, 10:38:19 PM »
If you need some help let me know.
I'll just need to know if your project has a single source file or multiple source files and what version of EBasic/IWBasic you have.
 
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

Offline PK

  • Newbie
  • *
  • Posts: 13
  • Bananas: 0
  • Gender: Male
  • I haven't set any personal text yet
Re: Global Variables in Projects
« Reply #3 on: August 23, 2013, 10:59:19 PM »
Help would be appreciated.

Ebasic Version 1.598

Source in approx 30 subroutines

Can make Global Variables work for a single program

Thanks

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Global Variables in Projects
« Reply #4 on: August 23, 2013, 11:14:20 PM »
assuming all your subroutines are in one eba file in your project.
That means your $MAIN directive is a the beginning of that source file.
Simply add the definitions for your global variables right after your $MAIN directive and initialize them to what ever value you require..
 
Make sure you don't redefine any of those global variables in any subroutine or any place else.  Also, don't pass them as parameters to any of the subroutines.
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

Offline PK

  • Newbie
  • *
  • Posts: 13
  • Bananas: 0
  • Gender: Male
  • I haven't set any personal text yet
Re: Global Variables in Projects
« Reply #5 on: August 24, 2013, 05:41:10 AM »
As total length of program is approx 4K lines, each subroutine is a separate eba file

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Global Variables in Projects
« Reply #6 on: August 24, 2013, 12:08:19 PM »
The following is from the ionicwind.com/forums:

The PROJECTGLOBAL preprocessor switch allows using the same file to both define project-wide globals and define them as external when the file is $included into other project files.  for variables you want global
create a file called Globals.iwb (or eba) and put the following in it
Code: [Select]
'global variables accessable to all modules
PROJECTGLOBAL "on"
  window mywindow
  int blah
  string blahblah
PROJECTGLOBAL "OFF"
add the file to your project
Add the following line to the top of every other source file in your project
Code: [Select]
$include "globals.iwb"  ' or eba-----------------------------------
for subs
create sub
Code: [Select]
global sub test(int param),int
'...blah blah
return x
endsub
In every other source file where you want to use the sub enter this line at the top of the source file
Code: [Select]
declare extern test(int param),int
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

Offline PK

  • Newbie
  • *
  • Posts: 13
  • Bananas: 0
  • Gender: Male
  • I haven't set any personal text yet
Re: Global Variables in Projects
« Reply #7 on: September 10, 2013, 08:04:21 PM »
Thanks for your help.

PK

Offline peaslee

  • Newbie
  • *
  • Posts: 21
  • Bananas: 0
  • Gender: Male
    • Campanile Data Systems
Re: Global Variables in Projects
« Reply #8 on: September 15, 2013, 11:54:50 AM »
Here is a way to pass values to dialog subroutines (or any routines for that matter as dialogs are global).
Code: [Select]
Type CostItemDialog 'extended dialog type
 Def dlg   as dialog
 Def bNew  as bool
 Def nRow  as int
 Def sType as string
EndType
'-------------------------
CostItemDialog dlgCostItem
Now, if you want to tell the dialog (in this case) that the record it is to create is a new one:
Code: [Select]
dlgCostItem.bNew = True
DoModal dlgCostItem
 
Bruce Peaslee

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Global Variables in Projects
« Reply #9 on: September 15, 2013, 01:34:33 PM »
Pretty neat Bruce.  I've never see it done that way.
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

 

To link to us use this code/button on your site

http://www.codingmonkeys.com/images/cm_link.gif

ShoutBox!

 

lurkalot

September 20, 2017, 01:57:54 PM
Hey that's my job. Didn't choose this username for nothing you know.  :)
 

Larry McCaughn

September 19, 2017, 12:24:13 AM
lurking in the shadows, lurkalot.
 

lurkalot

September 16, 2017, 04:39:43 PM
Good evening all.  Where is everyone?
 

lurkalot

September 12, 2017, 12:57:36 PM
Good to hear, it's nice to see a empty error log. ;)
 

Blue Steel

September 12, 2017, 05:04:25 AM
running sites log files overnight heres the result (I know mainly spiners) "There are currently no error log entries." :)
 

lurkalot

September 12, 2017, 03:19:33 AM
Morning all.  :)
 

Blue Steel

September 12, 2017, 01:12:33 AM
Let it all out ..
these are the things I can't do without  ;)

MikeHart

September 11, 2017, 11:14:22 PM
SHOUT SHOUT  :)
 

GWS

September 11, 2017, 08:16:02 PM
Shouting is Go !  ;D
 

Blue Steel

September 11, 2017, 06:54:02 PM
gradually getting there
 

lurkalot

September 11, 2017, 05:22:46 PM
Yay, you found it.  ;)
 

Larry McCaughn

September 11, 2017, 01:07:13 PM
looks like you're making good progress
 

Blue Steel

September 07, 2017, 10:34:19 PM
yay recent topics are working again in the center of the home page :)
 

Larry McCaughn

July 12, 2017, 05:46:33 PM
Blue Steel is back running the show.  Maybe he'll be able to build some steam in the ole place!
 

Blue Steel

June 26, 2017, 04:58:41 AM
hope i didn't scare too many of you
 

Blue Steel

June 26, 2017, 04:58:12 AM
Boo, i'm still here alive and well , see my post in introductions

MikeHart

July 25, 2016, 01:43:24 AM
That sounds cool. Have to chekc out IWBasic in the next days.
 

Larry McCaughn

July 22, 2016, 11:47:00 PM
I'm hoping to issue a new maintenance release to the IWBasic 3.x IDE in the next few weeks and Larry Sikes has released an update to the Linux version of IWBasic and is currently working on the 64bit version of IWBasic.  Progress should speed up since he has retired and has apparently resolved his m

MikeHart

July 19, 2016, 02:53:02 PM
Anything interesting going on around BASIC?
 

Larry McCaughn

July 18, 2016, 09:14:12 AM
Hello Mike

MikeHart

July 16, 2016, 04:33:25 PM
Hi there all!
 

pistol350

June 24, 2016, 03:41:10 AM
Hello all!
I'm still around although less active!
 

Blue Steel

September 08, 2013, 09:34:55 AM
first page of games in arcade are fixed. only 12 more pages to go
 

Blue Steel

September 08, 2013, 08:41:09 AM
Cleared all highscores on the games . i've been asked to see if i can fix them all. please PM me if you find a game in the arcade that doesn't work, there are way too many for me to go through each and every game.