Forum Moderators: coopster & phranque

Message Too Old, No Replies

Statements

if/else; while; for; do/while and so on and so on

         

circuitjump

3:27 pm on Feb 15, 2002 (gmt 0)

10+ Year Member



Just wanted to see if we can talk about statements. Doesn't matter what language you use it in. The basics of them is the same.

What do you use the if statement for?
Do you use while loops or for loops and what are the benefits?
Have any of you found a nifty way of using any of these statements?

If there is anything I'm missing put it on this thread. That way it becomes a big thread on statements!:)
thanks

Brett_Tabke

4:36 pm on Feb 15, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



if statement:

The cornerstone of all programming. The if statement or conditional statement is what gives all software it's "intelligent" behavior. It's used in programs as a decision point.

If one thing is true, then do this, else do the other.

(on a zen note: after years of programming, you will reach programming Nirvana and realize that your life is just one big if then statement).

(I'll leave the LOOPs to someone else).

txbakers

4:38 pm on Feb 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I begin my classes by saying that all programming comes down to this basic example:

If Raining then
bring umbrella
end if

On my email, this is my signature:

do while project<>completed
if impossible then
rethink(approach)
set impossible = false
end if
loop

circuitjump

3:50 pm on Mar 6, 2002 (gmt 0)

10+ Year Member



I'm bringing this post back to the front because I seriously would like to know what people think of certain statements, what looks to be used the most(if { else }) and all sorts of other stuff that I'm sure people got bouncing around there head.

Thanks :)

txbakers

6:06 pm on Mar 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I like the Select Case statement, but don't use it too often in javascript because I can never remember the syntax.

As for the While - I devised a nifty method of using ASP code to create HTML level breaks on reports. Very nice presentation.

But for me it all comes down to lots and lots of IF statements.

circuitjump

7:55 pm on Mar 6, 2002 (gmt 0)

10+ Year Member



The while loop and if statements are my favorites. The others I rarely use at all. But one of the best things I've found when coding in any language is user-defined Functions. Makes my life a little easier. ;)

txbakers

9:50 pm on Mar 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is also a zen thing:

I give my variables real names such as "betty", "dave", "suzie", steve, etc.

so in Vb script:

dim steve
steve = "Hello"
document.write("steve")

dim suzie
suzie = 35
suzie = suzie + 35

if suzie > 50 then
bob = "hello"
end if

jatar_k

9:54 pm on Mar 6, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



while and foreach are good stuff.
I use a few switch cases but they seem over the top most times.

joshie76

2:28 pm on Mar 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So true: "your life is just one big if then statement"...

We even have event handlers...

<person onBladderFull="goToWC()">