Author Topic: Help :)  (Read 5867 times)

0 Members and 1 Guest are viewing this topic.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Help :)
« Reply #15 on: June 11, 2009, 11:19:29 AM »
0
*TM made a mainloop without a goto  :o... sorry... got a little teary there....  :'(

Cerveza hasn't been keeping up on world events or checking my code.  GOTOs have use whether he likes it or not. Especially in EUO just because of the strange way the parser works.  I'd rather code something in 5 minutes, than work for 2 hours trying to figure out a "clever" way to eliminate all gotos.  I'd rather write clever scripts.  :)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline KilroyIsDead

  • Full Member
  • ***
  • Posts: 155
  • Activity:
    0%
  • Reputation Power: 2
  • KilroyIsDead has no influence.
  • Respect: +13
  • Referrals: 0
    • View Profile
Re: Help :)
« Reply #16 on: June 11, 2009, 12:16:21 PM »
0
You can most certainly use GoTo's - that's why the command exists; however, there is a time and a place. TM's example though is a good way to run your main loop without one, the "Repeat" tells the loop to run and the "Until" criteria is never met thus it loops indefinitely

Most importantly, if you DO use a GoTo, NEVER (repeat - NEVER) use GoTo to hop between subs.

I have 2 cents (4 actually)
I use goto consistently, but as stated I never use it to jump outside a sub.  Most of my scripts have each sub with a exit_SubName, most of this is learned behaviour, but I do it to ensure that the correct clean up always takes place and to me a single point of exit form a procedure is more sacred that not using gotos.
When choosing between repeat .. unitil and While, there is an important distinction.  The while is top tested so you can check to see whether or not you quailfy to run the loop before the first attempt, the repeat .. until is bottom tested so you're already committed to one cycle before doing any checks. Both are valid just make sure to remember this.

The repeat .. until used to be my favorite because I used to create boolean vars like TheCowsComeHome or HellFreezesOver and the code looked like
Repeat
 Do something
Until TheCowsComeHome

That still makes me chuckle.  But I use the while more often so that I can test before executing the first cycle.

 Ack!  btw, Great job on a first script always a nice feeling
« Last Edit: June 11, 2009, 12:29:57 PM by KilroyIsDead »
Give a man a fire, he'll be warm the rest of the night;
Set a man afire, he'll be warm the rest of his life.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Help :)
« Reply #17 on: June 11, 2009, 12:28:49 PM »
0
Don't get Cerveza started, he's the Unibomber of anti-GOTO use.  lol
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline KilroyIsDead

  • Full Member
  • ***
  • Posts: 155
  • Activity:
    0%
  • Reputation Power: 2
  • KilroyIsDead has no influence.
  • Respect: +13
  • Referrals: 0
    • View Profile
Re: Help :)
« Reply #18 on: June 11, 2009, 12:33:55 PM »
0
Don't get Cerveza started, he's the Unibomber of anti-GOTO use.  lol

He don't scare me I have a boat and know how to use it.

--Gone Fishin' --
Give a man a fire, he'll be warm the rest of the night;
Set a man afire, he'll be warm the rest of his life.

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Help :)
« Reply #19 on: June 11, 2009, 01:51:12 PM »
0
Oh Jeez! Now combining two of my hates in the same post....

Code: [Select]
if %fishing = #TRUE
goto DeleteUOandKillMyself
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Help :)
« Reply #20 on: June 11, 2009, 01:55:41 PM »
0
Ok, now I really am laughing out loud, right here in my kitchen.

:-)
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Tags: