Scramble Me App in Win32Lib
include win32lib.ew
without warning
global function main(sequence pArgs)
createForm( {
-- Initial 'Scramble Me' form
"Window, name=scramWin, caption=Scramble Me"
,
"Label, caption=Enter your name:, at=(8,8)"
,
"EditText, name=editName,"
& "at=(**, *+0)," -- left=same as previous, top=previous bottom
& "width=224"
,
"Button, Scramble Me,"
& "at=(**, *+4)," -- left=same as previous, top=previous bottom + 4
& "width=88"
,
"Button, Quit,"
& "at=(editName-88, **)," -- left=previous right - 88, top=previous top
& "width=88,"
& "flag=autoclose" -- This button will close the window.
} )
return 0
end function
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
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"))
include w32start.ew