Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
@Foreach Question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Parham  
View profile  
 More options Jul 3 2008, 3:22 pm
From: "Parham" <parha...@gmail.com>
Date: Thu, 3 Jul 2008 22:52:23 +0330
Local: Thurs, Jul 3 2008 3:22 pm
Subject: @Foreach Question

Hi,
I had a question. This is the code of a very simple cellphone I created. Every child of generic_cellphone has a number, and this is how the code is supposed to work:
Go through all the children of generic_cellphone with @foreach, and if the number attribute on any of them equals the number typed after the call command (the command syntax being call *), say connected, else say cannot find the target specified.
Well, as you can see, there is one thing wrong with this algorithm. If the generic_cellphone has 100 children, then the fail message will be given 99 times. But how can I fix this?
And is there something like a break command, for example, suppose we have three cellphones and the second one matches. The @foreach should stop immediately, how can I do that one?
Thanks!
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Young  
View profile  
 More options Jul 3 2008, 2:52 pm
From: William Young <youngwill...@hotmail.com>
Date: Thu, 3 Jul 2008 14:52:05 -0400
Local: Thurs, Jul 3 2008 2:52 pm
Subject: RE: [TinyMUX] @Foreach Question

The method I tend to lean on for phone-number code is a bit of a cheat, using the dbref of the target object as the core of the phone-number. So if your database doesn't have anything over dbref #9999? Then trying to dial Cell Phone Object #1966 would be the in-character phone number 555-1966 (and dialing Cell Phone Object #867 would be 555-0867). Obviously, if you're up in the five digit range for dbrefs (or higher) one can change the prefix (so it's 550-1966 or whatever is required).

That way, the code just checks to see if the target dbref has the Cell Phone Parent as a parent, allowing the call to go through if it works out.

Unfortunately, this doesn't solve the initial @foreach question.

T'Then...
William D. Young

Real Mail 42 Winter St, Bangor ME, 04401
E-Mail youngwill...@hotmail.com

From: parha...@gmail.com
To: tinymux@googlegroups.com
Subject: [TinyMUX] @Foreach Question
Date: Thu, 3 Jul 2008 22:52:23 +0330

Hi,
I had a question. This is the code of a very simple
cellphone I created. Every child of generic_cellphone has a number, and this is
how the code is supposed to work:
Go through all the children of generic_cellphone
with @foreach, and if the number attribute on any of them equals the number
typed after the call command (the command syntax being call *), say connected,
else say cannot find the target specified.
Well, as you can see, there is one thing wrong with
this algorithm. If the generic_cellphone has 100 children, then the fail message
will be given 99 times. But how can I fix this?
And is there something like a break command, for
example, suppose we have three cellphones and the second one matches. The
@foreach should stop immediately, how can I do that one?
Thanks!
---
Contact info:
Skype: parham-d
MSN:
fire_lizard16 at hotmail dot com
email: parham90 at GMail dot
com

_________________________________________________________________
Enter the Zune-A-Day Giveaway for your chance to win — day after day after day
http://www.windowslive-hotmail.com/ZuneADay/?locale=en-US&ocid=TXT_TA...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark  
View profile  
 More options Jul 3 2008, 3:20 pm
From: Mark <tiny...@jts.homeip.net>
Date: Thu, 03 Jul 2008 20:20:05 +0100
Local: Thurs, Jul 3 2008 3:20 pm
Subject: Re: [TinyMUX] @Foreach Question

You could use a recursive function call instead of the @foreach.

It have been a very long time since I did any tux coding, but the
principle would be to create a function that took as parameters:

1. The number you were looking for.

2. The list of child objects.

The function looks at the list of child objects.  If it is empty, then
the number hasn't been found, so return #-1.

Otherwise, use the first() item in the list of child objects, and
match() on the number attribute.  If this is found, the function returns
the object id.

If it isn't found, then the function calls itself with the number you're
looking for, and rest() of the list of objects.

There's some trickery needed so you don't always evaluate the rest()
part, but I don't remember this in enough detail to give you an example.

Another way of tackling this problem would be to build a list of numbers
from children, then do a single match on that, and use the index of the
match to get back to the child object id.

Hope that helps a bit,

Mark
(aka Mark Farrell @ ATS a long long time ago)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
A Character  
View profile  
 More options Jul 3 2008, 4:53 pm
From: A Character <a_charac...@hotmail.com>
Date: Thu, 3 Jul 2008 13:53:41 -0700
Local: Thurs, Jul 3 2008 4:53 pm
Subject: RE: [TinyMUX] @Foreach Question

th lsearch(,ething,\[match(%0,get(##/phonenumber))\])
________________________________


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
A Character  
View profile  
 More options Jul 3 2008, 4:56 pm
From: A Character <a_charac...@hotmail.com>
Date: Thu, 3 Jul 2008 13:56:47 -0700
Local: Thurs, Jul 3 2008 4:56 pm
Subject: RE: [TinyMUX] Re: @Foreach Question

Apparently it stripped out something.  lsearch(all or lsearch(player if it owns all the cell phones


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Parham  
View profile  
 More options Jul 4 2008, 12:28 am
From: "Parham" <parha...@gmail.com>
Date: Fri, 4 Jul 2008 07:58:32 +0330
Local: Fri, Jul 4 2008 12:28 am
Subject: Re: [TinyMUX] Re: @Foreach Question
Hello,
I believe that would be what I'm looking for, but there is no help for
lsearch, and I don't know the syntax, and when I put it in think, it gives
back the same thing to me. I mean this:
lsearch(all,ething,\[match(%0,get(##/phonenumber))\])
And this is the code I have put, which does nothing:
@va generic_cellphone=$call *:@dolist
[children(num(generic_cellphone))]=ifelse(lsearch(all,ething,\[match(%0,get (##/number))\]),say
works,say doesn't work)
Thanks.
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
A Character  
View profile  
 More options Jul 4 2008, 5:22 am
From: A Character <a_charac...@hotmail.com>
Date: Fri, 4 Jul 2008 02:22:12 -0700
Local: Fri, Jul 4 2008 5:22 am
Subject: RE: [TinyMUX] Re: @Foreach Question

Guess who is used to PennMUSH?  That's right, ME!
You want 'help search()' for syntax and all that jazz.

And probably something like:
@va generic_cellphone=$CALL *:Th Pemit(%#,If(Search(all ething=\[match(%0,get(##/NUMBER))\]),Works,Doesn't work))


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Parham  
View profile  
 More options Jul 4 2008, 7:58 am
From: "Parham" <parha...@gmail.com>
Date: Fri, 4 Jul 2008 15:28:37 +0330
Local: Fri, Jul 4 2008 7:58 am
Subject: Re: [TinyMUX] Re: @Foreach Question
Hello,
I TH'ed each part and figured that this,
th If(Search(eval=match(1,get(##/NUMBER))),Works,Doesn't work))

works, while EThings doesn't, since it says there is no such thing. So I
think what you wanted to put was eval, which evaluates each object. But
still, although I know a cellphone with the number 1 exists, this piece of
code,

>@va generic_cellphone=$CALL:Th
>Pemit(%#,If(Search(eval=match(1,get(##/NUMBER))),Works,Doesn't work))

won't work. I've tried the \['s and \]'s, but they don't make a difference
either.
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google