Scramble Function

All we need now is code to scramble the name that the user enters and display that in a dialog box.

Our scramble() function looks like this:

function scramble(sequence s) -- it's a generic function to scramble a string sequence
sequence result
integer i
    result = ""
    while length(s) > 0 do
        i = rand(length(s))
        result &= s[i]
        s = s[1..i-1] & s[i+1..length(s)]
    end while
return result
end function

wxEuphoria Scramble Event

For wxEuphoria, place the scramble function right above the Click_QuitButton procedure. Then, add this procedure after the Click_QuitButton procedure:

procedure Click_ScrambleButton(atom this, atom event_type, atom id, atom event )
    if message_box ( scramble(get_text_value(name)) , get_text_value(name) & " Scrambled", wxOK ) then end if
end procedure
set_event_handler(ScrambleButton, get_id(ScrambleButton), wxEVT_COMMAND_BUTTON_CLICKED, routine_id("Click_ScrambleButton"))

Run the program and you'll have a fully-functioning Euphoria GUI program!

Win32Lib Scramble Event

For Win32Lib, add the function after the form definition call, then add the following after that and before the 'include w32start.e' line:

global procedure Click_ScrambleMe(integer self, integer event, sequence parms)
    VOID = message_box( scramble( getText(getNameId("editName")) ), getText(getNameId("editName")) & " Scrambled", MB_OK )
end procedure
registerRoutine("Click_ScrambleMe", routine_id("Click_ScrambleMe"))

Run the program and you'll have a fully-functioning Euphoria GUI program!

On the next few pages, you'll see the complete program for each of the featured GUI libraries. After that, I'll give you some suggestions for choosing the Euphoria GUI library that's right for your application.