problem with script editor

Non-platform specific questions.

problem with script editor

Postby Joshua Worth » Sat Sep 10, 2005 10:59 am

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?
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby makslane » Sat Sep 10, 2005 12:03 pm

What's problem?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Joshua Worth » Sat Sep 10, 2005 12:09 pm

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
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby makslane » Sat Sep 10, 2005 8:13 pm

Ok, I will try solve
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby makslane » Sat Sep 10, 2005 8:14 pm

For now, try avoid big lines
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby jazz_e_bob » Sat Sep 10, 2005 10:55 pm

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);
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby BeyondtheTech » Sun Sep 11, 2005 2:49 am

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.
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

Postby jazz_e_bob » Sun Sep 11, 2005 4:29 am

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);
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby Joshua Worth » Sun Sep 11, 2005 4:45 am

Yeah, my dad told me that
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby ondy1985 » Sun Sep 11, 2005 12:31 pm

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
Image

Motto: "I never let my schooling interfere with my education" --- Mark Twain
User avatar
ondy1985
 
Posts: 99
Joined: Thu May 05, 2005 7:43 pm
Location: Slovakia
Score: 1 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron