Ok, I didn't think about that 1's. Here you go.

Code:
$replacex($duration(_____),wks,$chr(32) $+ weeks $+ $chr(44),days,$chr(32) $+ days $+ $chr(44),hrs,$chr(32) $+ hours $+ $chr(44),mins,$chr(32) $+ minutes and,secs,$chr(32) $+ seconds,wk,$chr(32) $+ weeks $+ $chr(44),hr,$chr(32) $+ hour $+ $chr(44),min,$chr(32) $+ minute and,sec,$chr(32) $+ second)


Just as a note... this isn't perfect. If you have 0 seconds, then you're left with something like:

4 hours, 5 minutes and

I'm not quite sure how to easily make the "and" either be there or not depending on if there are any seconds. Also, note that if all you have are weeks or hours (only one item), you'll end in a comma like this:

1 week,

This is the same issue as with the "and".

Granted, these aren't going to be seen too often, but they are there.

Now that I think of it, you might try this:

Code:
    var %duration $duration(___)
    var %weeks $iif($gettok($gettok(%duration,1,119),-1,32) isnum,$gettok($gettok(%duration,1,119),-1,32),$null)
    var %days $iif($gettok($gettok(%duration,1,100),-1,32) isnum,$gettok($gettok(%duration,1,100),-1,32),$null)
    var %hours $iif($gettok($gettok(%duration,1,104),-1,32) isnum,$gettok($gettok(%duration,1,104),-1,32),$null)
    var %minutes $iif($gettok($gettok(%duration,1,109),-1,32) isnum,$gettok($gettok(%duration,1,109),-1,32),$null)
    var %seconds $iif($gettok($mid($gettok(%duration,1,101),-3,2),-1,32) isnum,$gettok($mid($gettok(%duration,1,101),-3,2),-1,32),$null)

    if (%weeks) {
      if (%weeks > 1) {
        set %time %weeks weeks
      }
      else { set %time %weeks week }
      if ((%days && %hours) || (%days && %minutes) || (%days && %seconds) || (%hours && %minutes) || (%hours && %seconds) || (%minutes && %seconds)) {
        set %time %time $+ $chr(44)
      }
      elseif (%days || %hours || %minutes || %seconds) {
        set %time %time and
      }
    }

    if (%days) {
      if (%days > 1) {
        set %time %time %days days
      }
      else { echo -a Test2 | set %time %time %days day }
      if ((%hours && %minutes) || (%hours && %seconds) || (%minutes && %seconds)) {
        set %time %time $+ $chr(44)
      }
      elseif (%hours || %minutes || %seconds) {
        set %time %time and
      }
    }

    if (%hours) {
      if (%hours > 1) {
        set %time %time %hours hours
      }
      else { set %time %time %hours hour }
      if (%minutes && %seconds) {
        set %time %time $+ $chr(44)
      }
      elseif (%minutes || %seconds) {
        set %time %time and
      }
    }

    if (%minutes) {
      if (%minutes > 1) {
        set %time %time %minutes minutes
      }
      else { set %time %time %minutes minute }
      if (%seconds) {
        set %time %time and
      }
    }

    if (%seconds) {
      if (%seconds > 1) {
        set %time %time %seconds seconds
      }
      else { set %time %time %seconds second }
    }

    echo -a %time
    unset %time


This large code should do everything correctly no matter what amount of time there is. Stick it into whatever event you need it in, or as an alias.

Just replace the echo line with whatever kind of output you want instead of echo.

If you have problems, let me know.


Invision Support
#Invision on irc.irchighway.net