Click the links below to explore the different sections of our site. If you have any questions about our products or services, don't hesitate to contact us.
Following are a number of links to pages that might interest you as a visitor of this web site.
copyright © 2005-07 by Mark Schonewille & Economy-x-Talk

Economy-x-Talk - Sample Scripts

Combinations

The Combinations function returns all possible combinations of characters in a string, if each character may occur once.





function combinations theData
  put empty into myNewData
  repeat with myLineNr = 1 to number of lines of theData
    put line myLineNr of theData into myLine
    repeat with x = 1 to number of chars of myLine
      put myLine into myTemp
      delete char x of myTemp
      if number of chars of myTemp is 2 then
        put myTemp & return & char 2 of myTemp & char 1 of myTemp into myTemp
        repeat with y = 1 to number of lines of myTemp
          put char x of theData & line y of myTemp & return after myNewData
        end repeat
      else
        put combinations(myTemp) into myMoreTempData
        repeat with z = 1 to number of lines of myMoreTempData
          put char x of myLine before line z of myMoreTempData
        end repeat
        put myMoreTempData after myNewData
      end if
    end repeat
  end repeat
  return myNewData
end combinations

on calculate
  ask "Enter a string..." with "abcd"
  if it is not empty then
    get combinations(it)
    answer "Number of combinations is:" && (number of lines of it)
  end if
end calculate





Keep this extensive resource of tutorials and samples on-line! Support RunRev.info!
Yes, this script is useful. I make a donation and choose freely how much I want to donate on-line (PayPal). Click here if you want to make a donation in dollars.This script has not (completely) solved my problem and I want Economy-x-Talk to take care of it. Let me contact you.
Copyright©2002-2008 by Mark Schonewille, Nijmegen, the Netherlands. This web site is in no way affiliated with Runtime Revolution Ltd., but we do recommend the Revolution development platform.