Xojo "Indirect"

Does Xojo have an “indirect”-type of function?

Dim x As Integer
Indirect("x") = 6
System.DebugLog("x = " + Str(x)) ' x = 6

By indirect do you mean a function that interprets / evaluates some Xojo code as a String? If so, not really. You could use XojoScript to achieve something akin to that but there is no Eval() function like in Ruby.

Thanks, Garry. “Indirect” I think is the function in Excel…

One thing I REALLY miss from all the other languages I use is using {} inside strings to add formatted variables. In VB (and C# has this too) it’s:

Dim x As Double = 9.9999
Console.WriteLine($"The value of x is {x:#.##}") ' The value of x is 9.99

In JS it’s:

Var x = 9.9999;
Console.Log(`The value of x is ${x.toFixed(2)}`); // The value of x is 9.99

Thinking of writing my own extension, but that could prove challenging…

What I think is really cool is the “print” functions of Swift…
Similar to what Meestor_X posted above

print("The value of X is \(x) and Y=\(y) and sum=\(x+y)")

values can also be assigned to strings

Not to put you off @Meestor_X but it would be a challenge to add string interpolation (the fancy term for your VB / C# example) as a non-native extension. You’d have to tokenise the string, parse it and then interpret it which means you’re writing a runtime interpreter for Xojo…

Yeah, Pie in the Sky, really.

Disappointed though that all other (serious) languages have this and Xojo doesn’t. I hate having to use “+” and Str() around everything for strings. Yes, I am THAT anal and lazy…

Joe strout wrote one ages ago

let me find it
String Utils has a “sprintf” function

its abotu as close as I think you’ll get without having to revise the compiler & language itself :stuck_out_tongue:

FWIW, I converted Joe’s plugin to API2.


Too bad you posted it on a subscription site… I don’t do those after having a few violate my privacy.

you don’t need to subscribe to get the link of Jeannot’s github…