Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Dither Black and White Image - Imaging Lingo
Editable Field/Text AutoTabbing
Print Any Frame from Projector
zLaunch
Set ImageEnabled Property of a Flash Sprite
ini-script
CD-ROM Drive Letter Finder-Using a File
simFTPServer Xtra 1.0 Beta
Effector Set I for Alphamania
Set FrameRate of a Animated GIF Sprite
MediaMacros Xtras Mall
 

 

 

Behavior Palindrome Check

Added on 5/21/2001

 

Compatibilities:
behavior D7 D8 D8_5 Mac PC Shockwave

This item has not yet been rated

Author: KurtKoenig (website)

Checks a word to see if its a palindrome

Download PC Source    Download Mac Source
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--   PALINDROME CHECK
--
--   Use a repeat loop to check if the characters (or numbers) in the first half of a
--   field are equal to the characters in the last half, starting from the last one.
--
--   Kurt * Belgium     05/14/2001
--
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
on mouseup me
  
  --First this behavior counts how many characters there are in your word,
  --and puts this number in a variabele.
  Characters = (member "Word").chars.count
  
  --The number of characters is divided in two (integer division), so the repeat
  --loop can compare the characters in the first half with the characters in the last half
  Firsthalf = Characters / 2
  
  --The value in Palindrome is used later, when its equal to the value in Firsthalf;
  --the word is a palindrome.
  Palindrome = 0
  
  repeat with I = 1 to Firsthalf
    --If the first character = the last character Palindrome's value gets increased
    if (member "Word").char[I] = (member "Word").char[Characters] then
      Palindrome = Palindrome + 1
    end if
    
    --The last character becomes the last but one ("I" will represent the second
    --character in the next loop)
    Characters = Characters - 1
  end repeat
  
  --If the two values match, it's a palindrome,it doesn't matter if the word has
  --an odd number of characters, the one in the middle isn't compared to anything.
  if Palindrome = Firsthalf then
    alert "This is a palindrome !"
  else
    alert "This is not a palindrome !"
  end if
  
end mouseup

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail