Poll

Use brackets in your REPEAT/UNTIL loops or are you bracketless?

Brackets { }
No brackets
I do both and never really thought much of it
I don't know what a loop is

Author Topic: REPEAT/UNTIL Loops - Do you use brackets or none?  (Read 9303 times)

0 Members and 1 Guest are viewing this topic.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #15 on: February 07, 2010, 01:53:41 PM »
0
I agree with Twinkle McNugget, although some scripts like my Suit Builder are hard to read even with brackets  :( I can't even understand it anymore.
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline Paulonius

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #16 on: February 07, 2010, 07:29:25 PM »
0
Just a little feedback on an idea I saw in this thread posted by Twinkle McNugget and credited to Roadkill regarding putting a wait 1 into loops.  I was running a script that runs a mainloop with lots of checks that for the most part won't do anything, so it cycles really fast.  When I had two of them running it amped my CPU load from 5% to 44%.  When I dropped a "Wait 1" into the mainloop it dropped the load back down to 15%.  Something to think about when building scripts that hold a loop for any amount of time.
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Scrripty

  • Guest
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #17 on: February 07, 2010, 08:02:43 PM »
0
Just a little feedback on an idea I saw in this thread posted by Twinkle McNugget and credited to Roadkill regarding putting a wait 1 into loops.  I was running a script that runs a mainloop with lots of checks that for the most part won't do anything, so it cycles really fast.  When I had two of them running it amped my CPU load from 5% to 44%.  When I dropped a "Wait 1" into the mainloop it dropped the load back down to 15%.  Something to think about when building scripts that hold a loop for any amount of time.

UO is based on pretty big waits for actions... anything faster than like 1/10th of a second is pretty much a waste unless it's SERIOUSLY important you do it like RIGHT NOW. :)  Or doing TONS of calcs...  You can take it a step further Paul for great control with using like #sysTime or #sCnt/2  :)  According to RK and my own testing it sure helps scripts not be so "laggy." Glad that helped ya.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #18 on: February 18, 2010, 12:13:11 PM »
0
Yeah, in ALOT of my scripts I have things like.

set %Lobject_Timer #Scnt2 + 10
%Cast_Timer #Scnt2 + %Fcr_Delay

For Generic things, AKA You can't use an object yet, or you can't cast yet. And then beyond that you also set the rest of your timers.

set %EO1 #scnt + 360

etc etc
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline Superslayer

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #19 on: February 18, 2010, 12:25:56 PM »
0
the if statment without brackets will always read the 2nd line weather the 1st line is commented out or blank....

not sure if alot of ppl realize this but you can also tell the if statement how many lines are in the statement.  if You ask me its very tough to keep track of this exspecially if you edit a script.

Code: [Select]
start:
if #Findking = -1 2
   ignoreitem #Findid
   goto start
does the same thing as
Code: [Select]
start:
if #FindKind = -1
   {
   ignoreitem #findId
   Goto Start
   }

but this will only read the next line if the statement is true.
Code: [Select]
Start:
If #FindKind = -1
Ignoreitem #findID ; if the statement is true this line will be read
goto Start ; this line will always be read since its not bracketed.

I've been using this as of late, and found that it also works with 'else' statements.  Very cool feature imo.

Offline Paulonius

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #20 on: February 18, 2010, 12:38:17 PM »
0
EN, can you throw up an example?
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #21 on: February 18, 2010, 05:40:09 PM »
0
EN, can you throw up an example?

???? Of ?
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Superslayer

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #22 on: February 18, 2010, 08:40:36 PM »
0
In the event Paul may have meant me,:

This is the same :
Code: [Select]
if %Alpha = %Delta
{
  do stuff
  do more stuff
  finish doing stuff
}
else
{
  don't do stuff
  don't do anything else
  finish not doing something
}

as this:
Code: [Select]
if %Alpha = %Delta 3
  do stuff
  do more stuff
  finish doing stuff
else 3
  don't do stuff
  don't do anything else
  finish not doing something

Offline UOMaddog

  • Maddog
  • Elite
  • *
  • *
  • Posts: 1625
  • Activity:
    0%
  • Reputation Power: 22
  • UOMaddog might someday be someone...UOMaddog might someday be someone...UOMaddog might someday be someone...UOMaddog might someday be someone...
  • Gender: Male
  • Biggest B@D@$$ of the Universe
  • Respect: +165
  • Referrals: 8
    • View Profile
    • Insane UO
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #23 on: February 18, 2010, 09:55:17 PM »
0
I wish EUO would let me do my traditional Java formatting:

Code: [Select]
if this==that {
   blah blah
   yadda yadda
}

do {
  sumthin sumthin
} while fail==true

I like my brackets to start at the end of the line and then finish off the statement. It even makes 1 liners look nice. This is the standard format that Eclipse uses and I would personally love to have sex with Eclipse because it makes scripting so easy!
There are 10 kinds of people in this world: those that understand binary and those that don't!

Windows:  A 64-bit tweak of a 32-bit extension to a 16-bit user interface for an 8-bit operating system based on a 4-bit architecture from a 2-bit company that can't stand 1 bit of competition!

Offline Paulonius

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #24 on: February 18, 2010, 11:18:10 PM »
0
I did SS, thank you.  Sorry EN, not getting enough sleep.  

I mean I did mean you in that previous post, not "I did have sex with eclipse..."
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Katu

  • Jr. Member
  • **
  • Posts: 43
  • Activity:
    0%
  • Reputation Power: 2
  • Katu has no influence.
  • Respect: +5
  • Referrals: 0
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #25 on: March 25, 2010, 01:24:32 PM »
0
I use em, becouse i think it makes the code look cleaner. Im used to C languages so brackets makes sense. Ofcourse with "IF's" i dont always use, if theres just one line to do. In some cases, there needs to be lots of "IF's" and set variable then return. If using brackets, it takes almost 2x lines to do it. Then i might use the number to let EUO know, how many lines to process.
Ill use brackets even with subs.

Offline rana70

  • Elite
  • *
  • *
  • Posts: 294
  • Activity:
    0%
  • Reputation Power: 5
  • rana70 has no influence.
  • Gender: Male
  • Respect: +37
  • Referrals: 2
    • View Profile
    • MyScripts
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #26 on: March 26, 2010, 09:24:00 AM »
0
There are still places in the UO script Community
 .. where a script without brackets ...
even if it works ...
is considered tooooo bugy to be proven :-)

 ;) :'(

Offline BadManiac

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #27 on: March 26, 2010, 07:22:33 PM »
0
Always brackets and indentation everywhere. Consistency is king in programming. Brackets with if's, while's, repeat's, sub's. ALWAYS brackets!!!

Offline Katu

  • Jr. Member
  • **
  • Posts: 43
  • Activity:
    0%
  • Reputation Power: 2
  • Katu has no influence.
  • Respect: +5
  • Referrals: 0
    • View Profile
Re: REPEAT/UNTIL Loops - Do you use brackets or none?
« Reply #28 on: March 26, 2010, 11:07:43 PM »
0
Always brackets and indentation everywhere. Consistency is king in programming. Brackets with if's, while's, repeat's, sub's. ALWAYS brackets!!!
Agree 100%

Tags: