# Mintoris Forum

### Author Topic: True/False Constants  (Read 4442 times)

#### Jesse

• Sr. Member
• Posts: 126
• If life throws a planet at you, pull your ripcord‼
##### True/False Constants
« on: Apr 08, 2011, 04:35 AM »
Basic doesn't have the concept of constants yet, so we can use global variables instead. There are some that i use in just about every program. Two of them are true and false. A revision to basic once broke my true/false logic because of the assumption i made about how basic handled boolean logic, and i was right enough that it initially worked, but then quit working. So I've found a way to define true and false that should always work, regardless of any future revisions.

Global True, False
True = (1 = 1)
False = not True

I realize this is simple stuff, but it once stumped me, so maybe it'll help someone

Jesse

#### BillK

• Full Member
• Posts: 26
##### Re: True/False Constants
« Reply #1 on: Apr 09, 2011, 01:36 PM »
Jesse, good tip‼  I like the idea of built-in constants for True and False.  I tried to declare globals for these, but with using Include files, things got complicated over the point of where to declare them. So, for now, I'll use "Select Case 1=1".

BTW:
Print Not 1   ' output is 0 <--- Logical operator Not
Print ~ 1  ' output is -2  <--- Bitwise operator Not

Not is still described under Bitwise Operators in reference index. Shows example: "Not 3 = -4".  However, Not 3 = 0.  This had changed in version 3.4 with the introduction of the tilde operator.

/ Bill

#### Chuck

• Global Moderator
• Hero Member
• Posts: 1899
##### Re: True/False Constants
« Reply #2 on: Apr 09, 2011, 06:49 PM »
Not is still described under Bitwise Operators in reference index. Shows example: "Not 3 = -4".  However, Not 3 = 0.  This had changed in version 3.4 with the introduction of the tilde operator.

Opps, I've updated the reference to correct this.  Thanks for bringing it to my attention.

btw: false = 0, true = any non-zero number (usually true = 1 for functions like isFile("test.txt") ).  This is unlikely to change in the future.
« Last Edit: Apr 09, 2011, 07:51 PM by Chuck »

#### Jesse

• Sr. Member
• Posts: 126
• If life throws a planet at you, pull your ripcord‼
##### Re: True/False Constants
« Reply #3 on: Apr 11, 2011, 10:18 PM »
Bill, understand things getting complicated with include files. I'm taking a slightly different approach to using basic than i had previously. A multi bas file 'project' will include a single project bas file, a global declarations and initializing bas file, then a series of worker bas files. That way the confusion is lessened to a degree, for me anyway, by having all globals in the same place. Also  what I'm calling the project file is the only bas file in the Mintoris.Basic dir, where basic keeps its files, to keep things tidy and neat. This files purpose is only to include the other files and then call the main sub. The call to main() is below the include statements to give each included file an opportunity to do its own initializing by adding the init code outside of subs, which will of course get executed on basics way down to the call to main().

On another note, bill, the small project I've been working on today needed a file browser/picker. So with a little modification, I'll have open and save dialogs to compliment your works i should have it up by the end if the week.

#### BillK

• Full Member
• Posts: 26
##### Re: True/False Constants
« Reply #4 on: Apr 12, 2011, 02:34 AM »
Jesse, your approach of a common include file makes sense. Anxious to see an example of how your project file calls the included program.  Is it because all programs have a sub called "Sub Main()"?   My root directory has become quite untidy‼ I'm going to have to make heavy use of Astro in the next couple days.
The file/browser sounds great. I've programmed a file picker (not saver).  But I wrote it to pick files for a source formatting program I'm working on ( finished but still acid testing).
Also, it will be really nice once we get the Run command and we can pick files in any directory to run‼

/ Bill

#### Jesse

• Sr. Member
• Posts: 126
• If life throws a planet at you, pull your ripcord‼
##### Re: True/False Constants
« Reply #5 on: Apr 12, 2011, 06:37 AM »
Bill, we kinda got off topic, so I sent you a PM (private message). Forgot to mention though, that I use a sub main() once in one of my included files. It's just a starting point. The 'project file' simply includes all the other files that make the app, then starts the program by calling the sub called main(), which does some initialization and then goes to the mainmenu(). Mintoris basic isn't object oriented yet, so there can only be one sub main(). You don't even have to call it that. I just needed to call it something…

I posted that little something I told you I was working on. Check out the file picker dialog and see if it'd fit into your includes. If you think it'll work ok with your includes, let me know.

#### Chuck

• Global Moderator
• Hero Member
• Posts: 1899
##### Re: True/False Constants
« Reply #6 on: Jul 08, 2016, 07:37 PM »
True and False are now pre-defined system constants as of Basic 7.3

Basic Constants