Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Posts
    572

    i tray to revers a text like "dany maor" to "roam ynad"

    i tray to revers a text like "dany maor" to "roam ynad"

    i hev a code bat i dont know how to prosid
    -----------------------------------------------
    result = Input.GetText("Input1");
    size = String.Length(result);

    numLoopCount = 1;
    repeat
    --the code
    numLoopCount = numLoopCount + 1;
    until numLoopCount == size;
    ------------------------------------------------
    in "the code" i wont to take the "d" and put it on thename[1] and take the "a" and put it on thename[2] and the end put all in inutbox/ how i prosid????

  2. #2
    Join Date
    May 2005
    Posts
    1,115
    Code:
    result = Input.GetText("Input1");
    reverse="";
    
    for count=String.Length(result), 1, -1 do
    reverse=reverse..String.Mid(result, count, 1);
    end
    Never know what life is gonna throw at you.
    (Based on a true story.)

  3. #3
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Lua 5.1 has a string.reverse function built into it, but AutoPlay uses Lua 5.0. Here's some code to add a fast string.reverse function to 5.0, which will automatically switch to the built-in string.reverse function if AutoPlay ever upgrades to Lua 5.1 (which may or may not happen in a future version).

    Code:
    -- string.reverse is built into Lua 5.1, but AutoPlay 6 uses Lua 5.0...
    -- this test will revert to the built-in string.reverse function 
    -- if it becomes available to AutoPlay in the future
    if not string.reverse then
    	-- function string.reverse: returns a reversed version of the string you pass to it
    	function string.reverse(s)
    		local reversed = "";
    		-- Use string.gsub to iterate through the string, calling a temporary function
    		-- on each character. The temporary function just appends the character to the
    		-- beginning of our "reversed" string.
    		string.gsub(s,".",function(c)
    			reversed = c..reversed;
    			end);
    		return reversed;
    	end
    end
    I haven't profiled this to determine whether it's faster, but it should be a bit faster due to the internalized temporary function.

    I've attached a sample project demonstrating its use.
    Attached Files
    --[[ Indigo Rose Software Developer ]]

Similar Threads

  1. Replies: 33
    Last Post: 02-02-2007, 12:56 PM
  2. Example: Loading Paragraph Text Using a Timer
    By Jonas DK in forum AutoPlay Media Studio 5.0 Examples
    Replies: 7
    Last Post: 11-25-2004, 05:10 PM
  3. Display Text by Mouse Over of Image Object
    By jdanniel in forum AutoPlay Media Studio 4.0
    Replies: 3
    Last Post: 04-30-2003, 12:05 PM
  4. HOWTO: Display Conditional Text Based Upon a List Box Selection
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-15-2002, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts