Thread

Index > Scribe > From script, how do I prompt user for an integer?
Author/Date From script, how do I prompt user for an integer?
Scott
14/11/2022 7:32am
I've written a script to archive / delete mail recursively from a folder.
It works nicely apart from having hard-coded constraints for the filter.
Ideally, a GUI would pop up which would allow the user to select the various parameters such as duration and whether to delete or archive and where to archive.
For now, though, I'd settle for being able to prompt the user for the duration in years. I could write a Python script to create a GUI and then output the settings as a string. But I don't see any way to convert strings to integer.

How do I convert a user inputted string to an integer?
fret
15/11/2022 6:41am
The syntax for that is as follows:

str = "123";
myInt = str.int;


This is far from universal though, it works for 'int' and 'double' and only on string variants. You can't for instance do the opposite and use myInt.string to convert back to string. An oversight for sure.

There is an 'ICast' instruction that seems to be what we want here, but I can't remember the syntax to get the compiler to use it. Although it seems to support all the available types.
fret
15/11/2022 6:53am
I've added handling for 'int', 'string' and 'double' to inter-convert between those types.

so these work:

my_str.int;
my_str.double;

my_int.string;
my_int.double;

my_dbl.string;
my_dbl.int;

Reply