some boolean data type errors

General help with the eC language.
Post Reply
jonaspm
Posts: 49
Joined: Thu Apr 11, 2013 11:04 pm
Location: Mexico
Contact:

some boolean data type errors

Post by jonaspm »

Hello Jerome, redj and all the community!

Today i got some trouble, because i wrote this:

Code: Select all

class Form1 : Window
{
   /*WINDOW properties stuff...*/
   bool neg1=false;
   bool neg2=false;
then I have this:

Code: Select all

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         String negacion;
         String negacion2;
         if( this.neg1 == false){
            negacion = PrintString("");
         }else{
            negacion = PrintString("¬");}
         if( this.neg2 == false){
            negacion2 = PrintString("");
         }else{
            negacion2 = PrintString("¬");}
and the compiler jumps with some errors:

Code: Select all

Default Compiler
Building project Logica using the Debug configuration...
Compiling...
form1.ec
   form1.ec:16:13: error: syntax error
   form1.ec:16:13: error: syntax error
   form1.ec:17:13: error: syntax error
   form1.ec:17:13: error: syntax error
   form1.ec:16:14: error: couldn't find member false in class Form1
   form1.ec:161:4: error: couldn't determine type of this.false
   form1.ec:161:4: error: couldn't determine type of this.false
   form1.ec:161:4: error: couldn't determine type of this.false=
   form1.ec:161:4: error: couldn't determine type of this.false=

Logica.exe (Debug) - 9 errors, no warning   
lines 16 and 17 are:

Code: Select all

   bool neg1=false;
   bool neg2=false; 
Also, line 161 appears to not be the problem... (the compiler is unable to find the exact spot where the problem is, though I think it's related to the ifs above).


Thanks in advance! :)
jerome
Site Admin
Posts: 603
Joined: Sat Jan 16, 2010 11:16 pm

Re: some boolean data type errors

Post by jerome »

Hi Jonas,

At the moment it is not possible to initialize default values for properties together with their declaration within a class. However, you can do it separately, e.g.:

Code: Select all

class Form1 : Window
{
   /*WINDOW properties stuff...*/
   bool neg1, neg2;
   neg1 = false, neg2 = false;
Additionally, it is not necessary to initialize these values to 'false' as they would automatically be zeroed by default (and the value of 'false' is 0).

Another option would be to write a constructor:

Code: Select all

class Form1 : Window
{
   bool neg1, neg2;
   Form1()
   {
      neg1 = false;
      neg2 = false;
   }
}
Best regards,

Jerome
Post Reply