Page 1 of 1

problem with script editor

PostPosted: Sat Sep 10, 2005 10:59 am
by Joshua Worth
This is exactly what I did: I had 4 lines exactly the same length, each line 2 characters longer than the line. I went to the start of the second one and pressed <END>. I pressed <UP>, and I put in a semi-colon(;)on the end of the first line. I pressed down, and repeated that again for the rest of the lines. Can you fix that problem?

PostPosted: Sat Sep 10, 2005 12:03 pm
by makslane
What's problem?

PostPosted: Sat Sep 10, 2005 12:09 pm
by Joshua Worth
This was my code:
Code: Select all
switch(cloneindex){
    case 0:{ChangeAnimation("Event Actor", "1down", FORWARD);strcpy(reg_inputprint.text, "1");break;}
    case 1:{ChangeAnimation("Event Actor", "2down", FORWARD);strcpy(reg_inputprint.text, "2");break;}
    case 2:{ChangeAnimation("Event Actor", "3down", FORWARD);strcpy(reg_inputprint.text, "3");break;}
    case 3:{ChangeAnimation("Event Actor", "4down", FORWARD);strcpy(reg_inputprint.text, "4");break;}
           };
strcpy(reg_inputprint.text,inputpress);
Pretend the second line is the first line

PostPosted: Sat Sep 10, 2005 8:13 pm
by makslane
Ok, I will try solve

PostPosted: Sat Sep 10, 2005 8:14 pm
by makslane
For now, try avoid big lines

PostPosted: Sat Sep 10, 2005 10:55 pm
by jazz_e_bob
For maximum readability I recommend formatting switch/case systems in the following way:

Code: Select all
switch(cloneindex)
{
  case 0:
  {
    ChangeAnimation("Event Actor", "1down", FORWARD);
    strcpy(reg_inputprint.text, "1");
    break;
  }
  case 1:
  {
    ChangeAnimation("Event Actor", "2down", FORWARD);
    strcpy(reg_inputprint.text, "2");
    break;
  }
  case 2:
  {
    ChangeAnimation("Event Actor", "3down", FORWARD);
    strcpy(reg_inputprint.text, "3");
    break;
  }
  case 3:
  {
    ChangeAnimation("Event Actor", "4down", FORWARD);
    strcpy(reg_inputprint.text, "4");
    break;
  }
} // switch(cloneindex)

strcpy(reg_inputprint.text,inputpress);

PostPosted: Sun Sep 11, 2005 2:49 am
by BeyondtheTech
I believe you can do without the brackets between the case steps, no? I don't have any in mine and it seems to separate the functions properly.

PostPosted: Sun Sep 11, 2005 4:29 am
by jazz_e_bob
Hey - I didn't know that. Thanks mate.

Code: Select all
switch(cloneindex)
{
  case 0:
    ChangeAnimation("Event Actor", "1down", FORWARD);
    strcpy(reg_inputprint.text, "1");
  break;

  case 1:
    ChangeAnimation("Event Actor", "2down", FORWARD);
    strcpy(reg_inputprint.text, "2");
  break;

  case 2:
    ChangeAnimation("Event Actor", "3down", FORWARD);
    strcpy(reg_inputprint.text, "3");
  break;

  case 3:
    ChangeAnimation("Event Actor", "4down", FORWARD);
    strcpy(reg_inputprint.text, "4");
  break;

} // switch(cloneindex)

strcpy(reg_inputprint.text,inputpress);

PostPosted: Sun Sep 11, 2005 4:45 am
by Joshua Worth
Yeah, my dad told me that

PostPosted: Sun Sep 11, 2005 12:31 pm
by ondy1985
BeyondtheTech wrote:I believe you can do without the brackets between the case steps, no? I don't have any in mine and it seems to separate the functions properly.


The "break;" command tells the program to "jump out" from the switch statement.

EDIT: This page could be useful for non-native C-language speakers :D