XojoScript

An interesting question posed on TOF

is there any way to inject code into a control’s events at runtime?
Or, is there a way to create a function or sub procedure and create its methods, parameters, and insert code at runtime?

The consensus is, to alter compiled code – no. Which I agree with.

The suggestion was to investigate Xojoscript – which I also agree with.

And with careful planning and configuration you CAN make controls that can actually have their “event handlers” altered at runtime.

Here’s a very rudimentary sample that might spark some imagination & use

SVG for Xojo

There are a few Xojo coded SVG handlers

Most do a minimal level of SVG abut dont handle lots of extra fancy bits. Like proper clip path handling, defs with later uses sections, rotation, scaling, gradient fills and several others.

I’ve been lucky enough to get my hands on a VERY VERY VERY early test version of an SVG plugin.

I posted a movie of it in action on INN

Your most infuriating bug report ?

Mine is easy to list. A serious noticeable regression in the debugger.

http://feedback.xojo.com/case/59520
The debugger simply doesnt work as expected and the more I work the more infuriated I get that this bug has existed for over 2 years now

Voting for it hasnt gotten it fixed. And there are other similar bugs that seem related (like step not behaving a expected (http://feedback.xojo.com/case/68263)

Whats YOUR most important bug report for Xojo to fix ?
Bug – not feature request

Numbers 2022

Since the last numbers post Xojo has moved a lot of cases to an”archived” status which I believe is a lot like “we’re not spending time on this unless you say its still relevant”. As well they removed several “open” statuses like Reviewed.

Direct comparisons to my last numbers post are more difficult with these changes. As well its hard to get a list of which Archived cases I have asked to be reopened as they are still happening and that I still experience.

archived 61
closed (already exists) 10
closed (by design) 49
closed (duplicate) 54
closed (misc) 36
closed (no longer reproducible) 5
closed (not actionable) 7
closed (not reproducible) 48
fixed 18
fixed & verified 118
implemented 3
implemented & verified 16
open 425
resolved 2

In total theres been a little movement in the intervening 5 months but not a lot

Automating adding comments

In Xojo I often need to add in a comment about when I modified something or what I was working on
And the comment needs to be in a particular format – and it needs the current date & time as part of the comment
And, I want to be able to insert these EASILY into whatever code I’m working on right where the insertion point is

To do this I came up with this IDE Script that I saved in my Scripts dir next to the IDE

Dim stripped As String
stripped = DoShellCommand("echo ""// Updated `/bin/date ""+%Y-%m-%d %H:%M:%S %Z""` -- NJP"" | /usr/bin/tr -C -d ""[:print:]"" | /usr/bin/pbcopy -Prefer txt")

DoCommand("Paste")

this will make use of the DoShellCommand to get the unix shell to write a line with the current date in it, copy that to the clipboard, and then paste it right where the insertion point is

You can modify the unix shell commands used to do just about whatever else you want

Archived cases to be reopened

Posting this list here so its publicly known these exist & should be reopened
I’d post this list on TOF as well if I could

http://feedback.xojo.com/case/55562
http://feedback.xojo.com/case/55777
http://feedback.xojo.com/case/56094
http://feedback.xojo.com/case/56923
http://feedback.xojo.com/case/55319
http://feedback.xojo.com/case/57381
http://feedback.xojo.com/case/57380
http://feedback.xojo.com/case/56113
http://feedback.xojo.com/case/57125
http://feedback.xojo.com/case/56765
http://feedback.xojo.com/case/56233
http://feedback.xojo.com/case/57500

if you have your own list add to the thread on INN


Why you should subscribe to feedback cases

One of the criteria Xojo uses is number of voters (or subscribers) to judge how important a case is

Its been repeated that

I’m told it’s not that important to Xojo users or else they would have voted for it. So I’m going to rally the troops here and ask you to vote for it.

Because of how they rate importance it is important that you subscribe to bugs, not just read the case and hope Xojo does something about it.

Multiple return types dream

Suppose you want to do something like a set of preferences that are a simple key/value pairing.

A dictionary seems a great choice. Its keys can be any type and the values any type because both are variants.

So far so good.

Now you can do something like

dim i as integer = PrefsDict.Value("keyForIntegerValuedPreference")

And all seems great ! i gets an integer value and life is good

Except that this is ALSO legitimate

dim s as string = PrefsDict.Value("keyForIntegerValuedPreference")

And now your “strongly typed” system is fubarred. And the Xojo compiler will not complain

So how are you going to get an integer from something that SHOULD be an integer, and a string from something that should be a string ?
And get the compiler to help you do this ?

If you just use a dictionary you wont be able to. Its accessors dont have that capability.

You could try

GetValue(extends d as dictionary, key as variant) as Integer
GetValue(extends d as dictionary, key as variant) as String

but it wont work. Xojo doesn’t support multiple methods with the same signature and only differeing in return type 🙁

So how could you do this AND get the compiler to help you out ? What if instead of return values (which I will admit would be nicer) you do

GetValue(extends d as dictionary, key as variant, byref value as Integer)
GetValue(extends d as dictionary, key as variant, byref value as String)

and so on for every type ?

Now the compiler will tell you when you try to do something unsupported.
In our example with only integer and string values supported if we did

dim d as double
PrefsDict.GetValue("keyForIntegerValuedPreference", d)

the compiler would tell us this isnt supported

Its about the best we can hope for until/unless Xojo alters the compiler to permit several return types (and does the correct work to make use of it) In theory Xojo could make it so the compiler matched the right signature with the right return type to whatever is expected (like the following)

Dim i as integer = PrefsDict.GetValue("keyForIntegerValuedPreference") // would call the integer returning version
dim s as string = PrefsDict.GetValue("keyForStringValuedPreference") // would call the String returning version