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 redrocket · May 24, 2010 at 06:26 PM · for-loopsqlite

More than one row in an array not displaying in a FOR loop

Hello everyone.

I've got 5 columns and over 1300 rows of data which I've managed to retrieve into an array called: resultArray. I'm using the following loop to try and display each row into a corresponding GUIText variable:

        for (var value : String in resultArray)
    {
        hud.openPrice = resultArray[0];
        hud.highPrice = resultArray[1];
        hud.lowPrice = resultArray[2];
        hud.closePrice = resultArray[3];
        hud.volumeNum = resultArray[4];     
        yield WaitForSeconds (1);           
    }

I get the first row of data to display perfectly, however, every subsequent row doesn't display. What am I not doing?

Comment
Add comment · Show 1
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 Eric5h5 · May 24, 2010 at 08:47 PM 0
Share

I edited "solved" out of the title...that's not necessary here; please accept the answer ins$$anonymous$$d.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Eric5h5 · May 24, 2010 at 07:09 PM

Your loop is just doing the same exact thing over and over again, by assigning the first five entries in "resultArray" to the "hud.*" variables. Presumably you want to do something with the "value" variable, which is currently going unused.

Comment
Add comment · Show 2 · 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 redrocket · May 24, 2010 at 07:25 PM 0
Share

the value variable was there for printing to the console. that line of code isn't in the loop(...print(value)...). When I do include it, however, it prints all the values within the array one after the other. How would you get row after row of data then? Should I put the code in in a different loop?

avatar image Eric5h5 · May 24, 2010 at 07:41 PM 0
Share

@redrocket: $$anonymous$$aybe something like for (i = 0; i < resultArray.Length; i += 5) { hud.openPrice = resultArray[i]; hud.highPrice = resultArray[i+1]; etc.

avatar image
0

Answer by redrocket · May 24, 2010 at 08:28 PM

Eric,

Thanks for the insight, here's the working code:

    for (i = 0; i < resultArray.length; i += 5) 
    { 
        hud.openPrice = resultArray[i]; 
        hud.highPrice = resultArray[i+1];
        hud.lowPrice = resultArray[i+2];
        hud.closePrice = resultArray[i+3];
        hud.volumeNum = resultArray[i+4];
        yield WaitForSeconds (1);
    }

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 Eric5h5 · May 24, 2010 at 08:46 PM 0
Share

I'm glad it works, but ins$$anonymous$$d of writing "[SOLVED]", you're supposed to accept the best answer. That's how questions are marked solved.

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

1 Person is following this question.

avatar image

Related Questions

Building Unity game that includes SQLite database ,How to build Unity game that includes SQLite Database. 3 Answers

JS Loop question 2 Answers

the for statement in unity 3d for iphone 1 Answer

Need help cycling through an array with a 'for' loop. 0 Answers

My RPC gets called, but doesn't do the math before it 1 Answer


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