Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by IBDelta · Aug 16, 2010 at 12:46 PM · syntax-errorbce0044

Simple array usage

Can someone please tell me why this code doesn't work and show me how to fix it?

var TileNumberArray; TileNumberArray = new int(); TileNumberArray.Length = 80;

static var ResetButtonSetting = 1;

function Update () { for(TileArrayChoice=1;TileArrayChoice < TileNumberArray.Length; TileArrayChoice++); { TileNumberArray[TileArrayChoice] = ResetButtonSetting; }

}

I'm a noob at programming but this really should work as far as I can tell. The error code I get is as follows;

resetDialScript.js(12,42): BCE0044: expecting :, found '='.

Any help would be greatly appreciated.

"It's enough to make you chew your own foot off" - John Cleese

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bampf · Aug 16, 2010 at 01:24 PM

Remove the extra semicolon on the line where the loop is declared:

var TileNumberArray; TileNumberArray = new int(); TileNumberArray.Length = 80;

static var ResetButtonSetting = 1;

function Update () { for(TileArrayChoice=1;TileArrayChoice < TileNumberArray.Length; TileArrayChoice++) // ; <-- removed { TileNumberArray[TileArrayChoice] = ResetButtonSetting; }

}

== [Addendum] Now that the script actually compiles you will be able to run it. This will give you some new errors which indicate that early responses you got were also on the right track: the length parameter should not be capitalized, and the array declaration should be

TileNumberArray = new Array();

For reference, see the documentation page on Arrays.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image IBDelta · Aug 16, 2010 at 01:28 PM 0
Share

Cheers for trying but still no luck, same error message.

resetDialScript.js(12,42): BCE0044: expecting :, found '='

Which refers to this line

TileNumberArray[TileArrayChoice] = ResetButtonSetting;

avatar image IBDelta · Aug 16, 2010 at 01:40 PM 0
Share

Cheers, took unity a while to realise the script had changed, lol. Now I have something else to think on. Again thanks to all the people who have posted such quick replies, I am in your debt :-)

avatar image Bampf · Aug 16, 2010 at 01:44 PM 0
Share

No problem. Don't forget to vote up any replies that you find helpful, and (when possible) mark the checkbox on the one that best solved your problem.

avatar image
0

Answer by 3dDude · Aug 16, 2010 at 01:01 PM

ok well there are lots of problems in our code...

1# array.length is not capitalized.. and it is read only so you cant mod it in scripts;

2# your var should look like this:

var TileNumberArray : int[]; 

i'm not sure if these problems are the real problems because i'm a noob to ;).

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by vyruz · Aug 16, 2010 at 01:05 PM

hey there :)

i think array length is readonly!

and you cant say array=single_value

use array[index]=value instead

for (int x=0;x< TileNumberArray.Length;x++)

i would suggest learning programming concepts VERY WELL b4 diving into the deep sea of unity :) good luck!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image IBDelta · Aug 16, 2010 at 01:18 PM 0
Share

Would it be possible for you to post a fixed example of the script? Cheers :-)

avatar image
0

Answer by IBDelta · Aug 16, 2010 at 01:10 PM

Thanks for trying but there is no problem with the "Length" parameter, only the first letter needs to be capitalised, several variations show this is the only spelling that unity recognises as an internal command-thingy.

Removing the "new" before "int[]" has done nowt.

The problem points to this line;

TileNumberArray[TileArrayChoice] = ResetButtonSetting;

Again, your help was appreciated, ty

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bampf · Aug 16, 2010 at 01:30 PM 0
Share

FYI, you should delete this answer and post it again as a comment on the original answer. Thanks

avatar image
0

Answer by IBDelta · Aug 16, 2010 at 01:55 PM

Again, huge thanks to all those who have helped. For the sake of completion here is the finished code that provides no errors during runtime or otherwise;

var TileNumberArray; TileNumberArray = new Array();

var TileArrayChoice; static var ResetButtonSetting = 1;

function Update () { for(TileArrayChoice=0;TileArrayChoice<81; TileArrayChoice++) { TileNumberArray[TileArrayChoice] = ResetButtonSetting; }

}

whether it actually does what I expect it to do remains to be seen :-)

Again, a huge thanks to all

"I can see clearly now the rain has gone, I can see all obstacles in my way" - Johnny Nash

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bampf · Aug 19, 2010 at 12:38 PM 0
Share

Ins$$anonymous$$d of looping to 81, you should loop until TileArrayChoice >= TileArrayChoice.Length. This lets you change the size of the array (either in code or the inspector) without having to change any code.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Script error. Please Help! 4 Answers

'If' Statement in javascript giving me problems 3 Answers

BCE0044: expecting ':' found ';' 1 Answer

Basic on collision play animation code not working 1 Answer

BCE0044: expecting :, found '=' 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges