Scripting in GH Part 06

Software: 
Tag: 
Video Duration: 
8 minutes
Author: 
Zach Downey

In this tutorial we demonstrate the while loop by recreating the series component.  The key thing to remember when you use a while loop is that you are responsible for creating the initialization and iteration clauses.  I guess technically, no matter what kind of loop you create, you are responsible for these things.  However, with the while loop it is very easy to forget these.  It is also surprisingly easy to forget to make sure your statements meet your condidtion clause and actually end the loop--avoiding the dreaded infinite loop.

List<int> numbers = new List<int>();
 
int i = 0;
while (i < count) {
    numbers.Add((i*step) + start);
    i++;
}
A = numbers;

Rating

Please rate this tutorial below. Thanks.

5
Average: 5 (8 votes)

Comments

Some of the videos in this series are not available in HD, quite annoying because i can't read the code..
Sorry about that bayupu. I think some of those videos might need to be re-uploaded. I'll take a look and see which ones are in HD and which ones are in SD. There are a couple of videos that are being upgraded to HD now. The other videos, I'll need to dig up and re-upload. Most of these should have code snippets below, if you can't read the code on the screen.
The final code is also available immediately below the video. It seems the code we input always begins on line 90, so it's straightforward from there.

Want to Contribute?

Want to be an author? Drop us a line here we'd love to have you.

Already have a video you'd like to post? Send us a link and we'll get you going.

:)