ScriptSpot

Forum topic · General Scripting

warning and continue dialog problem (and more)

By Ralf · 2020-02-19

Description

Hello,i got (another) problem with my script



if ((ssRoll != undefined) and (ssRoll.isdisplayed)) do (destroyDialog ssRoll)

Rollout ssRoll "GearCreator V0.3" (
	group ""(
		spinner sp_w "width" type:#float range:[0.0,10,1]
		spinner sp_h "height" type:#float range:[0.0,10,1]
		button bt_create "Create Gear"
	)
	
	on bt_create pressed do( 
		
		BPs = sp_w.value *sp_h.value
		
		if BPs < 0.999 then (
			rollout bgaRoll "GearCreator Warning" 
				(
					label lbl_1 "WARNING:"
					label lbl_2  "Blablabla"
					label lbl_3  BPs as string
					button bt_back "go back" width:82 height:24 align:#left offset:[2,10]
					button bt_forw "make anyway" width:82 height:24 align:#left offset:[92,-29]
					on bt_back pressed do(destroyDialog bgaRoll)
					on bt_forw pressed do (jump to line 29) and (destroyDialog bgaRoll)    
				)
			createDialog bgaRoll 200 116
			) 
			else 
				(
				ss = rectangle name:"example" width:(sp_w.value) length:(sp_h.value)
				)	
		
	) --end create pressed
) --end rollout
	
createDialog ssRoll

q1- the 'on bt_forw pressed do' is wrong, but how do i continue anyway?

q2- the "BPs as string" is undefined. In my full script i use BPs a lott. should i write it easy time within the brackets, or is there another way?

tnx

Comments (2)

.

miauu · 2020-02-19


(
	if ((ssRoll != undefined) and (ssRoll.isdisplayed)) do (destroyDialog ssRoll)
	global ssRoll
	Rollout ssRoll "GearCreator V0.3" 
	(
		local BPs = 0
		group ""
		(
			spinner sp_w "width" type:#float range:[0.0,10,1]
			spinner sp_h "height" type:#float range:[0.0,10,1]
			button bt_create "Create Gear"
		)
		
		function CreateRectangle =
		(
			ss = rectangle name:"example" width:(sp_w.value) length:(sp_h.value)
		)
 
		on bt_create pressed do
		( 
			BPs = sp_w.value *sp_h.value
			
			if BPs < 0.999 then 
			(
				rollout bgaRoll "GearCreator Warning" 
				(
					local lbl_3_text = ""
					label lbl_1 "WARNING:"
					label lbl_2  "Blablabla"
					label lbl_3 lbl_3_text
					button bt_back "go back" width:82 height:24 align:#left offset:[2,10]
					button bt_forw "make anyway" width:82 height:24 align:#left offset:[92,-29]
					on bt_back pressed do(destroyDialog bgaRoll)
					on bt_forw pressed do
					(
						ssRoll.CreateRectangle()
						destroyDialog bgaRoll
					)
					
					on bgaRoll open do
					(
						lbl_3.text =  (ssRoll.BPs as string)
					)
				)
				createDialog bgaRoll 200 116
			) 
			else 
			(
				CreateRectangle()
			)	
	 
		) --end create pressed
	) --end rollout
 
	createDialog ssRoll
)

.

Ralf · 2020-02-19

Ah,thank you again, Miauu. You are great.
(and you have enpasant another problem solved. I get confused with local/global a lott)