TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Difference in #parse behavior using &0 vs $parse

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
moebius



Joined: 27 Jan 2005
Posts: 96

PostPosted: Thu Dec 08, 2005 1:19 am    Post subject: Difference in #parse behavior using &0 vs $parse Reply with quote

Code:
> #parse {a b c} {#showme [&0]}
[a]
[ ]
[b]
[ ]
[c]


vs.

Code:

> #parse {a b c} {#showme [$parse]}
[a]
[]
[b]
[]
[c]


I would much prefer using $parse in this situation as &0 interefers with function arguments.
_________________
StrangeMUD - strangemud.net:9332
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Thu Dec 08, 2005 5:49 pm    Post subject: Reply with quote

me too, I'll look into it =]
Back to top
View user's profile Send private message Send e-mail
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Thu Dec 08, 2005 5:55 pm    Post subject: Reply with quote

Thinking about it, you can probably use &&90 for #parse within a function as long as the function doesn't use the 9th argument.
Back to top
View user's profile Send private message Send e-mail
moebius



Joined: 27 Jan 2005
Posts: 96

PostPosted: Fri Dec 09, 2005 12:26 am    Post subject: Reply with quote

Hmm, I don't think that'd work here, it's entirely possible that I will use the 9th argument. (Also it's a such a hack Smile )

In fact, is there any way to use more than 10 in a function? In aliases, %0 acts as a catch-all so you can basically use as many as you want (so long as you don't care about individually addressing them), but there is no such thing for functions...

The alias is basically a say script, so the # of arguments is variable and could often be quite high. I was wanted to convert it @function so I could reuse it in different aliases but thinking about it now the 10 argument limit could be a big problem.

Although, I suppose I could make the function just take 1 argument, and call it with the sentence wrapped in { }, so it's one argument with spaces. I.e.

Code:
#alias mysay {say @msg{{%0}}}

_________________
StrangeMUD - strangemud.net:9332
Back to top
View user's profile Send private message
moebius



Joined: 27 Jan 2005
Posts: 96

PostPosted: Fri Dec 09, 2005 12:29 am    Post subject: Reply with quote

Wow. I just noticed you can't just call a function from within a function. Because when you define a function that calls another one, the function calls in the defination get executed immediately and their values are recorded in the function defintion. Ugh.

But you can do the &9 hack again. Wow, this is really getting ugly :/
_________________
StrangeMUD - strangemud.net:9332
Back to top
View user's profile Send private message
moebius



Joined: 27 Jan 2005
Posts: 96

PostPosted: Fri Dec 09, 2005 12:54 am    Post subject: Reply with quote

Continuing the conversation with myself, regarding the limitations of 10 arguments for functions.

Okay, doing

Code:
#alias mysay {say @msg{{%0}}}


only sort of works. Say I wanna make a tell alias. I want it to be usable just like the mud's normal tell, i.e. "mytell joe hey guess what I heard the other day?". So I have to get the first word out of the list before sending it to the function. I try this:

Code:
#alias mytell {
   #var args %0;
   #list del args 1;
   tell %1 @msg{{$args}};
}


which looks reasonable. Except when you do the list operation, the list stored in args is slightly changed; if $args was {a b c d e} before the del, it's {{b} {c} {d} {e}} after. Which in a list context is equivalent to {b c d e}, but in a string context, like when you pass it to the function wrapped in { }, it's much different. In fact, the alias won't even run, you'll get an "#Unmatched braces error".
_________________
StrangeMUD - strangemud.net:9332
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Fri Dec 09, 2005 7:22 pm    Post subject: Reply with quote

It doesn't work well indeed. You can use #forall to get rid of the braces but that's still a little tricky.

The &&90 thing is a bit of a hack, but at least it's a natural phenomenom and not something of my own creation Wink I should have thought of that sooner cause it's the main reason I added variables.

You can use #parse and a custom function to skip the first word and copy the rest as the result.

Code:

#function oneword
{
    #format oneword 0;
    #format result %s;
    #parse {&0}
    {
        #if {$oneword}
        {
            #format result %s%s {{$result} {&&90}}
        }
        {
            #if {"&&90" == " "}
            {
                #format oneword 1
            }
        }
    }
}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group