Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

CL: Undocumented Macro feature

 
   Macintosh computer (Home) -> Adventure RSS
Next:  CL: recorded by google for future generations to ..  
Author Message
rhdennis

External


Since: Jun 25, 2003
Posts: 53



(Msg. 1) Posted: Sat Jul 19, 2003 9:21 am
Post subject: CL: Undocumented Macro feature
Archived from groups: comp>sys>mac>games>adventure (more info?)

I just stumbled on another interesting undocumented feature similar in
nature to one Phineas wrote about some time ago. His involved setting
goto points via a variable. Turns out this is a VERY powerful feature
and I've used this extensively in my macros. (The upcoming Kill Counter
v3.0 uses it...expect it to be posted on <http://www.clmacros.com>
within the next few days)

I've discovered that you can actually set which condition will test via
a variable. Quite interesting and probably powerful.

Lets say we have the following set of data:

set nVar[0] "Test."
set nVar[1] "One Test."
set nVar[2] "Another."
set nVar[3] "Two Test."
set nVar[4] "Three Test."
set nVar[5] "And Another."

And now I want to read through this data and extract things based on
whether there are partal or exact matches. So the user enters what
they're interested in and we read it off the @text box; "/test
<something>" then enter.


"/test"
{
set index 0
set mustMatch "<=" //The default test looks for "contains"
if @text < "."
set mustMatch "==" //This condition means "exact"
end if

label loop
if index < 6

// Notice here you don't see the normal construction
// if <testcase> <test> <variable> where <test> is a set of
// conditions like: == for "equals", <= for "less than or equal",
// > for "greater than", etc.
// We stored which <test> in the variable mustMatch!

if @text mustMatch nVar[index]
message nVar[index]
end if

set index + 1
goto loop
end if
}

This routine will change whether it looks for a partial match '<=' in
the data or whether it looks for an exact '==' match based on whether
the user adds the period.

For example. if the user typed in Test (no period) the output would be:

Test.
One Test.
Two Test.
Three Test.

These are all the partial matches that contain the word "Test" in the
data set.

However, if the user added the period (Test.) then the output would be:

Test.

This is the only "exact" match to the word "Test." in the data.


Okay then, hope someone finds this as useful as I did. And I'll continue
exploring what things you can do with variables in the CL Macro language.

rhdennis

 >> Stay informed about: CL: Undocumented Macro feature 
Back to top
Login to vote
Hidden1

External


Since: Jun 24, 2003
Posts: 74



(Msg. 2) Posted: Sat Jul 19, 2003 9:21 am
Post subject: Re: CL: Undocumented Macro feature [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
<rhdennis-77D029.01214619072003.RemoveThis@newssvr30-ext.news.prodigy.com>,
rhdennis <rhdennis.RemoveThis@guess.sbcglobal.net> wrote:

 > Okay then, hope someone finds this as useful as I did. And I'll continue
 > exploring what things you can do with variables in the CL Macro language.

Cool discovery. This confirms my theory -- the macro engine is simpler
than we give it credit for. My take on the logic of the macro engine,
for those interested in this type of thing:

1) Function called
2) Iterate through lines
a) Replace all recognized variables first
I) If there's a . between the variable and
successive whitespace, process the variable
with the micro-command following the .
II) If there's a [(x)] between the variable and
successive whitespace, evaluate the inner
variable first. Caveat: global arrays only
recognize global indices, and vice versa.

b) Check for built-in commands. If there is one,
execute it. If not,
c) Add the line to the output buffer, stripping
any quotes. Flush the buffer to the server at
every \r.
3) Profit!!

My guesses at built-in command implementations:
set (x) [(+|-|*|/) y]: checks for the variable in a (possibly blank)
linked list received from the parent function, if there, modifies it
appropriately, if not, tacks it onto the end.
setglobal (x) [(+|-|*|/) y]: the same, but with a global linked list
instead of a more local one (probably statically declared in macro.c as
a global variable)

call (x): recursively invokes the macro evaluation function on the
specified macro, passing the linked list of local args and possibly
global args

goto (x): searches through the lines until the "label (x)" marker is
found.

if (x) (==|<|>|>=|<=) (y): tests the condition. if true, enters a
mini-eval-loop until either "else" or "end if" is detected. if false,
moves forward until either "else" or "end if" is detected, then
continues evaluation from there

pause (x): sleeps the thread for x/4.0909 seconds, which is why
pause-based timing isn't always perfect.

random [no-repeat]: this one's trickier, and since there are about a
hojillion roughly equal ways to implement it, I'm not going to bother
doing the guesswork.

message (x): prints (x) to the sidebar

DISCLAIMER: I do not have access to the client source files. The above
are just GUESSES based on extensive macro development experience, and
thus should not be taken as absolute gospel. If someone with access to
the client sources was allowed to fill us in on further details, that
would kick ass.

--
HWC for Hidden <hidden.RemoveThis@noDASHop.com> <http://www.oralse.cx/>
"Nothing says "Shut the Fuck Up" Like a baseball bat to the head."<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: CL: Undocumented Macro feature 
Back to top
Login to vote
rhdennis

External


Since: Jun 25, 2003
Posts: 53



(Msg. 3) Posted: Sat Jul 19, 2003 4:34 pm
Post subject: Re: CL: Undocumented Macro feature [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <hidden-3A4CA5.00553819072003 DeleteThis @news.stanford.edu>,
Hidden <hidden DeleteThis @no-op.com> wrote:

 > In article
 > <rhdennis-77D029.01214619072003 DeleteThis @newssvr30-ext.news.prodigy.com>,
 > rhdennis <rhdennis DeleteThis @guess.sbcglobal.net> wrote:
 >
  > > Okay then, hope someone finds this as useful as I did. And I'll continue
  > > exploring what things you can do with variables in the CL Macro language.
 >
 > Cool discovery. This confirms my theory -- the macro engine is simpler
 > than we give it credit for. My take on the logic of the macro engine,
 > for those interested in this type of thing:
 >

Thanks for the feedback ... might be right, but since you can "set"
built in function you might have to mess with your evaluation list a
tad. For those who don't know, you can actually do things like:

set @text <value>

Then can call a function that is supposed to look at the input
box...fooling it into accepting YOUR data instead. This is VERY useful
for things like assigning your own macro calls that looks at the input
@text box to fkeys like so:

<fkey>
{
set @text ""
call NewRoutine
}

This call to your routine will ignore any text already in the client's
input box. It would be the same as making the NewRoutine call with no
argument.


Now, on a completely different sidenote. I mentioned a week or so ago I
was interested in 2D arrays and was hoping someone had worked with them
a bit. Only Phineas replied so I'm having to sort of invent the wheel
here and I have the following problems:

// this works just like you'd expect.

"/exptest0"
{
set var[0] "I"
set var[1] "wonder"
set var[2] "whether"
set var[3] "this"
set var[4] "works."
set num1 0
set num2 0
label init_loop
if num1 < 5
set array[num1][num2] var[num1]
set num1 + 1
set num2 + 1
goto init_loop
end if
set num1 0
set num2 0
set temp ""
label start_loop
if num1 < 5
set temp + array[num1][num2]
set temp + " "
set num1 + 1
set num2 + 1
goto start_loop
end if
message temp
}


// this does not work....

"/exptest1"
{
set array[0][0] "I"
set array[1][1] "wonder"
set array[2][2] "whether"
set array[3][3] "this"
set array[4][4] "works."

set num1 0
set num2 0
set temp ""
label start_loop
if num1 < 5
set temp + array[num1][num2]
set temp + " "
set num1 + 1
set num2 + 1
goto start_loop
end if
message temp
}

// but this one does! ??? ... why? Whats going on here?

"/exptest2"
{
set array[0][0] "I"
set array[0][1] "wonder"
set array[0][2] "whether"
set array[0][3] "this"
set array[0][4] "works."

set num2 0
set temp ""
label start_loop
if num2 < 5
set temp + array[0][num2]
set temp + " "
set num2 + 1
goto start_loop
end if
message temp
}


If someone out there has some insight, I'd appreciate it.

I've also tried things like:
set nArray[index] "0 0 0 0 0"
from here you can read each "cell" with the following:

set fVar nArray[index]
if fVar.word[N] <condition> <testcase>

I thought I should be able to do it directly like:
if nArray[index].word[N] <condition> <testcase>
// but it didn't work =\

I was able to read the "array". I wasn't able to figure out how to
change any of the "elements". (Can't do any calculations because the
elements are "strings" bleh).


rhdennis<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: CL: Undocumented Macro feature 
Back to top
Login to vote
Display posts from previous:   
   Macintosh computer (Home) -> Adventure All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]