I have a canvas control that has to be a minimum of 33 pixels height or it’ll break at runtime with an error. Is there any way to check this at compilation time to give a message rather than getting an error at runtime. Something like this in open event
If me.Height < 33 Then
#Pragma Error "Control must be minimum of 33 pixels high"
End If
Obviously this won’t work but, hopefully, gives an idea what I’m trying to achieve. Just want to give a better/helpful message to the developer rather than a runtime error.
You are mixing water and oil here. “Compile time” and “Run-time”. Can’t do it.
Once the compiler find the “#pragma Error” during the compile time, it will raise the compiler error ignoring the run-time code around.
Triggering It should be isolated using compile-time decisions like #If#EndIf, but it’s not your case.
In other environments there is Design-time (for add-ons, plug-ins) and you could interact with the environment an take “kind of” such actions, like after a control resize, do some processing.
Should have been clear - my code was only pseudo code to try and get across what I’m trying to achieve. Obviously, the code won’t work for the reasons you’ve explained.
Not very nice though, the canvas control has to be minimum 33 pixels. It would be nice to be able to generate a nice compilation error accordingly. As it stands, the first a developer is going to know is when they get an ugly run-time exception.
[quote=105463:@Greg O’Lone]There is something you can do.
if me.height < 33 Then
#if DebugBuild
Msgbox "the zzz canvas must be at least 33 pixels wide at all times!"
#EndIf
End if[/quote]
Thanks Greg - may be the best I can do - maybe even tie that into an App.Quit to avoid the runtime error. I haven’t checked feedback but if there’s no way for us to generate our own compilation errors is it worth a feedback request? Is it doable from a Xojo IDE perspective?
If the canvas is being resized at runtime I’d understand the existence thing. I’ve set the Inspector Behaviour to have it’s height to be 33 but if the developer resizes the canvas in the IDE to be 30 then it’s a shame we can’t catch that at compilation. Even if we had Canvas.MinHeight/MinWidth properties, that would be helpful.