Notifications
Clear all

[Closed] stop createdialog from returning 'true'

I have function that looks for specified filepath.
if doesFileExist == true, it returns the filepath;
if doesFileExist == false, it use createdialog to popup a UI for the user to specify an alternative.
this gets called as part of a larger data gathering process.

the problem: createdialog returns true, which gets passed as a result of the function before the user can interact.

a simplified version:


fn findFile filename = (
		if doesFileExist (filename) then (
			format "FOUND:  %
" filename
			return filename
		)else(
			format "...handling Missing file...
"
			rollout popUp ("missing: " +filename )
			(
				--place holder rollout stuff
				fn closeMe=(DestroyDialog popUp)
				button btn "close"
				on btn pressed do
				(
					return "some alternative texture path chosen by user"
					closeMe()
				)
			)
			dialog=createdialog popUp ismodal:true width:330
		)
	),

Is there a way to prevent createdialog form returning true?

4 Replies

fn confirmFilename file: = 
(
	if iskindof file string and doesfileexist file then file else
	(
		rollout dialog "Alt Filename" width:200
		(
			local result 
			button confirm_bt "Confirm" width:90 align:#left offset:[-4,0] across:2
			button cancel_bt "Cancel" width:90 align:#right offset:[4,0] 
			
			on confirm_bt pressed do
			(
				result = "alt"
				destroydialog dialog 
			)
			on cancel_bt pressed do destroydialog dialog 
		)
		createdialog dialog modal:on
		dialog.result
	)
)

it’s the wrong argument name

thanks (again) Dennis

using


 local result

and


dialog.result

plus fixing


modal:on

did the trick.

the using of right things usually works