Ceej:

I made two very minor changes to your sript. I used case statements in the main loop only because in this particular case, all your buttons are mutually exclusive (or at least, that the easiest way to design this) and then I modifed the while loop in the fern function like this:


do

until $i=$at[0][4] or ($form.peekevent() and $cmdexit.click())

peekevent is the asynchronous version of getevent. getevent waits for user input and returns false only when the window closes, thats why you can use it in a loop like this:



while $form.getevent()

if $button.click
?"hi there"
endif

loop

peekevent returns true only if there's an event waiting in the event queue else it returns false right away. so the structure of an asynchronous event loop is different, like this:



while $form.visible
if $form.peekevent
if $button.click
$form.visible=0 ; stop the loop
endif
else
; there no event waiting so carry on processing forever ...
endif
loop

anyways, heres your script back at you. thanks for converting that:


break on


? "KiXForms IFS Fractal Generator"
? "Version 1.1 by cj"
?


; the fern
dim $fern[4]
$fern[0]=200,300,1,1,10000
$fern[1]=85,4,0,-4,85,40
$fern[2]=20,-26,0,23,22,40
$fern[3]=-15,28,0,26,24,11
$fern[4]=0,0,0,0,16,0
; Sierpinsky's triangle
dim $sierp[3]
$sierp[0]=300,300,1,1,20000
$sierp[1]=50,0,0,0,50,0
$sierp[2]=50,0,301,0,50,0
$sierp[3]=50,0,0,0,50,301
; A slightly modified Sierpinsky triangle
dim $sierp2[4]
$sierp2[0]=400,400,1,1,10000
$sierp2[1]=50,0,0,0,50,0
$sierp2[2]=50,0,300,0,50,0
$sierp2[3]=50,0,150,0,50,300
$sierp2[4]=25,0,225,0,25,150
; the dragon
dim $dragon[2]
$dragon[0]=200,300,1,1,10000
$dragon[1]=45,-50,0,40,55,0
$dragon[2]=45,-50,400,40,55,0
; a maple leaf - this one doesn't look right...
dim $maple[4]
$maple[0]=250,200,1,-1,10000
$maple[1]=49,1,25,0,62,-2
$maple[2]=27,52,0,-40,36,56
$maple[3]=18,-73,88,50,26,8
$maple[4]=4,-1,52,50,0,32


; create KiXForm
$form = createobject("kixtart.form")
$form.caption = "IFS Fractal test"
$form.visible=1
$Form.BackColor = 0 ; black background
$form.forecolor = $Form.RGB(0, 200, 0) ; a beautiful green


$cmdFern = $Form.CommandButton(560,55,65,25,"Fern")
$cmdSierp = $Form.CommandButton(560,80,65,25,"Sierpinsky")
$cmdSierp2 = $Form.CommandButton(560,105,65,25,"Sierpinsky2")
$cmdDragon = $Form.CommandButton(560,130,65,25,"Dragon")
$cmdMaple = $Form.CommandButton(560,155,65,25,"Maple")
$cmdExit = $Form.CommandButton(560,205,65,25,"Exit")


while $form.getevent


select
case $cmdFern.click() DrawIFS($fern)
case $cmdSierp.click() DrawIFS($sierp)
case $cmdSierp2.click() DrawIFS($sierp2)
case $cmdDragon.click() DrawIFS($dragon)
case $cmdMaple.click() DrawIFS($maple)
case $cmdExit.click() quit()
endselect


loop


function DrawIFS($AT)
$Form.BackColor = 0 ; clear the screen again
$i=0
; get image offset
$xoff=$at[0][0]
$yoff=$at[0][1]
; get image rotation
$xflip=$at[0][2]
$yflip=$at[0][3]

do
$t=rnd(ubound($at)-1)+1
$x=(($x*$at[$t][0])/100)+(($y*$at[$t][1])/100)+$at[$t][2]
$y=(($x*$at[$t][3])/100)+(($y*$at[$t][4])/100)+$at[$t][5]
; $form.circle(300-$x, 300-$y, 1) ; draw dot
$form.circle(-$xflip*$x+$xoff, -$yflip*$y+$yoff, 1) ; draw dot
$i=$i+1
until $i=$at[0][4] or ($form.peekevent() and $cmdexit.click())
endfunction