Ecere SDK/eC Forums • View topic - some boolean data type errors




Ecere SDK/eC Forums

Ecere Developers Community

some boolean data type errors

General help with the eC language.

some boolean data type errors

Postby jonaspm » Wed Mar 25, 2015 12:32 am

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! :)
jonaspm
 
Posts: 49
Joined: Thu Apr 11, 2013 11:04 pm
Location: Mexico

Re: some boolean data type errors

Postby jerome » Wed Mar 25, 2015 8:26 am

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
jerome
Site Admin
 
Posts: 622
Joined: Sat Jan 16, 2010 11:16 pm


Return to eC Language

Who is online

Users browsing this forum: No registered users and 1 guest

cron