Page 1 of 4

WARNING!! Serious revamp IS LIVE!!

Posted: Thu Oct 02, 2003 3:40 am
by Plazmic
Status: Code tested, time for everyone else to test it
It's in CVS and the zip. DKAA trumped me on letting people test it first ;)

I'm almost finished with what will probably be the single largest change ever (96k diff).
ALL $l/$v/$p/$t/$a() variables will be REMOVED!
Why you might ask?

They will be replaced with new variables, with REAL names (not #define'd)
Unlimited number of globals, locals, and timers
Multiple arrays of unlimited size, single dimensional or two dimensional
(Also tossed in are unlimited alert lists, but that's beside the point)
Variables will be referenced with the at sign (@) to seperate them from EQ variables
Subroutines will have named parameters (or if unnamed "Param0", "Param1", etc)

Old vars:

Code: Select all

#define AVAR v1
Sub Main
   /varset AVAR $p0
   /echo $AVAR was passed into the macro
   /if "$p1"!="" /echo A second value was passed in too.
/return
New vars:

Code: Select all

Sub Main(FirstArg)
   /declare VarName global
   /varset VarName @FirstArg
   /echo @VarName was passed into the macro
   /if $defined(Param1) /echo A second value was passed in too.
/return
Please give feedback on what you think of this change.

Posted: Thu Oct 02, 2003 4:38 am
by grimjack
I've been really wanting something like this for a really long time. Thanks for all the hard work plaz.

Posted: Thu Oct 02, 2003 6:11 am
by Random()
Good change, will be nicer to work with. Might want to post simple examples in the Macro:Help forum though before that forum gets turned upside down.

Amazing work

Posted: Thu Oct 02, 2003 6:40 am
by Ohmz
May god have mercy on SOE...

Posted: Thu Oct 02, 2003 10:34 am
by Amadeus
I bet someone could write a script or simple application that could convert old scripts to this new format. Or, at least get close ;)

Posted: Thu Oct 02, 2003 11:22 am
by Slice
When this happens I would suggest renaming the Macro Depot to Unconverted Macros (OLD).

Create a new macro depot where the authors can create new threads for the migrated macro and slowly lock the threads in the old folder.

Slice

great

Posted: Thu Oct 02, 2003 12:44 pm
by FlashG
/em bows to the lead deveoper and his minions

The work to convert macros will be worth it. Not to be picky but maybe we can DELARE our varibles and if not declared the interperter flag it as a error. I dont want to say how may times I have /varseted a varible and then missspelled it when I went to use it.

Flash - o fYi inc $

convert

Posted: Thu Oct 02, 2003 1:08 pm
by grimjack
I would like to start converting my bot macro and a few others asap so they are ready when this hits CVS. The only problem I have is not knowing what the exact syntax will be. Will #define still be present for instances where we would like to replace text? And last is there anything I need to know about creating array's. Do I declare them different?

Thanks for your time

GrimJack

Posted: Thu Oct 02, 2003 1:16 pm
by Zxeses
This change MUST be documented. Please dont commit this to CVS unless the end-users know exactly what we need to do.

Posted: Thu Oct 02, 2003 1:46 pm
by Scrime
Very, very nice Plaz. Looking forward to this change. But as mentioned by a previous poster, please provide some documentation so that we know exactly what we need to do to convert our macros.

Posted: Thu Oct 02, 2003 1:54 pm
by Plazmic
#define isn't being touched (#define MERCHANTNAME "Granger" will still work)

All variables will need to be /declare'd

Code: Select all

Usage: /declare <varname> <global|local|timer|array|array2>
Globals are the old $v#
Locals are the old $l#
Timers are the old $t#
Array is the new single dimensional array
Array2 is the new two dimensional array

Setting values is just like it was before

Code: Select all

/declare MyVar global
/declare MyTimer timer
/varcalc MyVar 100/2
/varset MyTimer 10s
/varsub MyVar 30
Variables are accessed via @<varname>
Variable existance can be checked via $defined(<varname>)

Code: Select all

/if $defined(MyVar)==TRUE /echo My variable is @MyVar
Array usage:

Code: Select all

/declare SmallArray array
/declare TwoDimArray array2
/varset SmallArray(2) 100
/varset TwoDimArray(50,96345) 33
/echo Array test: $calc(@SmallArray(2)/@TwoDimArray(50,96345))
Sub parameters:
For conversions sake, I default unnamed parameters to "Param#" which can be a quick search and replace for all $p# variables

Code: Select all

Old:
Sub Main
   /echo $p0
/return

New:
Sub Main
   /echo @Param0
/return
Parameters can also be named: (This is test.mac in HugeChange.zip)

Code: Select all

#chat tell 
Sub Main(paramBotOwner) 
   /if $defined(paramBotOwner)==FALSE {
      /echo Please pass in the owner's name
      /return
   }
   /declare gBotOwner global 
   /declare gShouldQuit global 
   /declare UselessTimer timer 
   /echo @paramBotOwner
   /varset gBotOwner @paramBotOwner 
   /varset gShouldQuit FALSE 
   /varset UselessTimer 3s 
   /echo My master is @gBotOwner
   :EventLoop 
      /doevents
   /if FALSE==@gShouldQuit  /goto :EventLoop 
/return 

Sub Event_Chat(ChatType,Sender,ChatText) 
   /if @Sender!=@gBotOwner /return 
   /echo @Sender sent me a @ChatType, '@ChatText' 
   /if "@ChatText"=="quit" /varset gShouldQuit TRUE
/return 

Sub Event_Timer(Timer,OriginalValue) 
   | Timer contains the NAME of the Timer variable 
   /echo @Timer went off. 
   /varset @Timer @OriginalValue 
/return

Posted: Thu Oct 02, 2003 2:39 pm
by dont_know_at_all
Mail the diff to all the devs so that we can test too.

This is going to cause a lot of squealing from idiots.

Overall, I like this change. I never liked the FORTRAN-like implicit declarations -- too easy to screw up.

Will "/define $p0 @param0" work?

Posted: Thu Oct 02, 2003 2:46 pm
by Slice
I would also suggest considering any other retooling that you've thought of doing at the same time. If we're going to go through a period of macro conversion due to language changes, do as much of it at once.

Slice

Posted: Thu Oct 02, 2003 5:26 pm
by Plazmic
dont_know_at_all wrote:Mail the diff to all the devs so that we can test too.

This is going to cause a lot of squealing from idiots.

Overall, I like this change. I never liked the FORTRAN-like implicit declarations -- too easy to screw up.

Will "/define $p0 @param0" work?
I will diff against a specific SRC-xxxx.zip and put it in the downloads directory.

"#define $p0 @Param0" could work for parameters, but you'd still have to modify all the $v/$t/etc, or #define and /declare each one...

Time to test it for the *FIRST* time... It'll either work great, or I'll have a stupid minor bug in a 5th level function that will blow everything up ;)

Posted: Thu Oct 02, 2003 6:21 pm
by ap50
Hold me, I'm scared.