LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Array assignments are illegal

hello,

 

can everybody tell me what is wrong in the code??

 Error: Array assignments are illegal /   Lvalue required.

 

thx


 

int CVICALLBACK GenerateCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
 char tmpLastStep[NAME_SIZE];
 
 switch (event)
 {
  //set the last step at LAST
  tmpLastStep = LAST;

  case EVENT_COMMIT:
   if( 0 == strcmp(tmpLastStep, "LAST" ) )
   {
    MessagePopup("Last Step","Here is the last step." ) ;

    
    CCSTemp.i16Step = LAST;
    CCSTemp.i16Fkt = FKT_END;
   }
   else
   {
    MessagePopup("Error","Error in Stepfile. Last Step not defined." ) ;
    error_write_main = 1;
   } 
    
   WriteStepFile(ARRAYID, ARRAYPORT, ARRAYBAUD,  ARRAYCALCULATION, ARRAYCHARACTISATION, ARRAYFILES,
       ARRAYORDNER);
    break;
 }
 return 0;
}

0 Kudos
Message 1 of 5
(5,035 Views)

the error tells you that array assignment is illegal.

 

look at your code, what array do you have ? only one,  tmpLastStep.

Is it assigned somewhere ? yes, line 8, tmpLastStep = LAST;

what is the problem with  this assignment ? first, we don't know the value of LAST, is it a string as this strcmp() later suggest, or is it an int as the rest of the code suggest (i16Step, the useless hungarian notation is useful here to tell that this variable is a short int) ? second, assignment  of a value to an array is illegal: there is a lot of reasons why this is this way (it is a reason of pointer and where the memory for the array is allocated), for the moment remember to never ever set your array this way ! to copy the content of an array to another array, use standard functions like memcpy() or strcpy(). 

 

another problem: the array assignment is INSIDE the switch but OUTSIDE any case statement, thus will NEVER be executed...watch out when you are writing code.

Message 2 of 5
(5,031 Views)

OK - I was beaten to the keyboard!

Message Edited by jr_2005 on 03-16-2009 11:10 AM
Message 3 of 5
(5,030 Views)

jr_2005 wrote:

"OK - I was beaten to the keyboard!"

 

i hope it did not hurt... i will try beating softer next time.

Message 4 of 5
(5,027 Views)

dummy_decoy wrote:

i hope it did not hurt... i will try beating softer next time.


You people are so polite. Kudos to both of you. Enjoy Smiley Wink

0 Kudos
Message 5 of 5
(5,024 Views)