Re: Convert T/F

2002-04-03 Thread Dave Cragg

At 4:20 pm -0800 2/4/02, Scott Rossi wrote:
Can true and false be converted into their numeric equivalents (1/0)?

to which he got a lot of replies showing, that if you try hard 
enough, you can make Metatalk just as unreadable as Perl or C.

itemOffset, bitwise operations, abs, referenced parameters . 
although, disappointingly,  no matrixMultiply (yet).

You're all mad. :)

function convertTF pWhich ##patent pending
  if pWhich is true then
   return 1
  else
   return 0
  end if
end convertTF

I bet it's faster too.

And I bet Scott was really looking for something else.

Cheers
Dave
___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Re: Convert T/F

2002-04-03 Thread Scott Rossi


 Can true and false be converted into their numeric equivalents 
 (1/0)?

 to which he got a lot of replies showing, that if you try hard enough, 
 you can make Metatalk just as unreadable as Perl or C.

 And I bet Scott was really looking for something else.

To which I respond true.

I assumed there was some built-in MetaTalk conversion for this but 
perhaps there isn't (surprising).  As for me, I like this one:

 itemoffset(tf,false,true)-1 

Thanks to all for the creative functions. :-)

Regards,

Scott Rossi
Creative Director, Tactile Media
[EMAIL PROTECTED]
http://www.tactilemedia.com

___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Re: Convert T/F

2002-04-03 Thread Scott Rossi

 I like this one:

  itemoffset(tf,false,true)-1 

Although

wordOffset(string,false true)-1

...works better in my situation since I'm dealing with the entire word 
and there's no need to initialize matches, etc.

Thanks again.

Regards,

Scott Rossi
Creative Director, Tactile Media
[EMAIL PROTECTED]
http://www.tactilemedia.com

___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Convert T/F

2002-04-02 Thread Scott Rossi

Can true and false be converted into their numeric equivalents (1/0)?

Regards,

Scott Rossi
Creative Director, Tactile Media
[EMAIL PROTECTED]
http://www.tactilemedia.com

___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Re: Convert T/F

2002-04-02 Thread J. Landman Gay

Scott Rossi wrote:
 
 Can true and false be converted into their numeric equivalents (1/0)?

The perfect chance to post one of my favorite handlers. Wish I'd written it:

function whichOne var,fld1,fld2 
-- from a handler by Tony Root
-- Handles a case where you need to return one value if your key is
empty, another if not.

  return (item offset(char 1 of (var = empty),tf) of quote  fld1
, fld2  quote)
end whichOne

You can adapt it to almost anything:

function whichOne var -- pass true or false
  return (item offset(char 1 of (var=true),tf) of 1,0
end whichOne
-- 
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software   | http://www.hyperactivesw.com
___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Re: Convert T/F

2002-04-02 Thread Ken Ray

Here's another way to do it:


function ConvertTF what
return abs(5-length(what))
end ConvertTF

Enjoy!

Ken Ray
Sons of Thunder Software
Email: [EMAIL PROTECTED]
Web Site: http://www.sonsothunder.com/

- Original Message -
From: J. Landman Gay [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 02, 2002 8:00 PM
Subject: Re: Convert T/F


 Scott Rossi wrote:
 
  Can true and false be converted into their numeric equivalents
(1/0)?

 The perfect chance to post one of my favorite handlers. Wish I'd written
it:

 function whichOne var,fld1,fld2
 -- from a handler by Tony Root
 -- Handles a case where you need to return one value if your key is
 empty, another if not.

   return (item offset(char 1 of (var = empty),tf) of quote  fld1
 , fld2  quote)
 end whichOne

 You can adapt it to almost anything:

 function whichOne var -- pass true or false
   return (item offset(char 1 of (var=true),tf) of 1,0
 end whichOne
 --
 Jacqueline Landman Gay | [EMAIL PROTECTED]
 HyperActive Software   | http://www.hyperactivesw.com
 ___
 metacard mailing list
 [EMAIL PROTECTED]
 http://lists.runrev.com/mailman/listinfo/metacard



___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Re: Convert T/F

2002-04-02 Thread Yennie

Hey, while we're at it:

on convertTF @tf
put the wholeMatches into saveMatches
set the wholeMatches to true
get (itemOffset(tf, false,true))
if (it  0) then put it into tf
set the wholeMatches to saveMatches
end convertTF

This will actually change the value of the variable IF it is true or false. 
Otherwise, it is untouched.
Just another variant...

Regards,
Brian
___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Re: Convert T/F

2002-04-02 Thread Dar Scott

My entry:

function tf bool
   return charToNum(char 3 of bool) bitAnd 1
end tf

Dar Scott


___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Re: Convert T/F

2002-04-02 Thread Dar Scott


On Tuesday, April 2, 2002, at 08:08 PM, Ken Ray wrote:

 function ConvertTF what
 return abs(5-length(what))
 end ConvertTF

I like this!

But why abs()?

If this doesn't need abs(), I think you might have the winning 
entry, Ken!

function ConvertTF what
 return 5-length(what)
end ConvertTF

Dar Scott

___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard



Re: Convert T/F

2002-04-02 Thread Ken Ray

Good point, Dar! When it went through my head, I was thinking of
(length(what) - 5) and needed the abs() to get a positive 1. However once it
went down in email, I forgot to remove it...

Thanks!

Ken Ray
Sons of Thunder Software
Email: [EMAIL PROTECTED]
Web Site: http://www.sonsothunder.com/

- Original Message -
From: Dar Scott [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 02, 2002 10:24 PM
Subject: Re: Convert T/F



 On Tuesday, April 2, 2002, at 08:08 PM, Ken Ray wrote:

  function ConvertTF what
  return abs(5-length(what))
  end ConvertTF

 I like this!

 But why abs()?

 If this doesn't need abs(), I think you might have the winning
 entry, Ken!

 function ConvertTF what
  return 5-length(what)
 end ConvertTF

 Dar Scott

 ___
 metacard mailing list
 [EMAIL PROTECTED]
 http://lists.runrev.com/mailman/listinfo/metacard


___
metacard mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/metacard