Personal Lessons

Go down

Personal Lessons

Post by Corey on Sat Dec 26, 2009 3:04 am

For Brad: Here is a Do-Loop tutorial.
Do/Loop can be used to repeat a segment of code either indefinitely, or until a certain condition has been satisfied.
The syntax is as follows:
Code:

Do  { Until | While } [condition]
[ statement block ]
Loop

---------------------------------------------

Do
[ statement block ]
Loop  { Until | While } [condition]

---------------------------------------------

Do
[statement block]
Loop

Please note that the last one is not recommended as it can render programs unstable. Use at your own risk.

_________________
-Corey Hoard

(Yes, I totally copied Paul's avatar. Or, at least attempted to.)
avatar
Corey
Mod

Posts : 462

Back to top Go down

Re: Personal Lessons

Post by Corey on Sat Jan 30, 2010 3:08 am

For Brad: Here is an If-Then tutorial.
If/Then can be used to execute if a certain condition is true. If it is, the code in the if block is executed. If not, then the code is skipped.
The syntax is a follows:
Code:

If [expression] Then [statement(s)] [Else [statement(s)]] End If
or
If [expression] Then : [statement(s)] [Else [statement(s)]] : End If
or
If [expression] Then
[statement(s)]
[ Else ]
[statement(s)]
End If



If...Then is a way to make decisions. It can also provide alternative code to execute based on more conditions.
A conditional expression, for example:
Code:
x = 5
x < 5
x > 5
x <= 5
x >= 5
x <> 5

Multiple conditions can be separated by logic operators, for example:
Code:
x > 5 And x < 10
x > 5 or y < 1
x > 7 xor v < 8

Both multi-line and single-line Ifs can be nested. In the latter case, the optional End Ifs can be useful to control where nested Ifs begin and end.
Code:

If x = 5 then
        print "hi"
        if y < 3 then
                  print "hola"
        else
                  print "adios"
        end if
end if
Code:
if w = 6 xor u = 7 then print "lol"
Code:
if x > 3 and i = 4 then:else:print "bye":end if

_________________
-Corey Hoard

(Yes, I totally copied Paul's avatar. Or, at least attempted to.)
avatar
Corey
Mod

Posts : 462

Back to top Go down

Re: Personal Lessons

Post by Lunsfordium on Tue Mar 23, 2010 5:02 am

what about arrays?
and strings?
avatar
Lunsfordium
[Blankie]

Posts : 194

Back to top Go down

Re: Personal Lessons

Post by Unchained on Tue Mar 23, 2010 6:57 am

For java?

Code:

Array:
vartype varname(size);

string:
string varname = "sup?";

Like that?

_________________
Life happens. - Zach (me)

All you've got to worry about is right here, right now. - David Lee Roth
avatar
Unchained
Mod

Posts : 448

Back to top Go down

Re: Personal Lessons

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum