Hi Pete, I think I've gotten the kinks worked out. This takes the time from a Text field and mine is named TextTime. You can use a different field name, just replace TextTime in the code and use your field name.
"// Get the minute/second separator index";
let mssIndex := index(TextTime, ":");
"// Convert minutes to seconds and add to seconds";
let ttlSec := number(substr(TextTime, 0, mssIndex)) * 60 + number(substr(TextTime, mssIndex + 1));
"// Divide total seconds by miles if miles isn't 0, otherwise, return TextTime";
if Miles != 0 then
let divTtlSec := ttlSec / Miles;
"// Calculate divided minutes";
let divMin := floor(divTtlSec / 60);
"// Calculate remaining seconds. Need to test for single digit seconds, e.g., :2 and multiply by 10";
let rmnSec := round(divTtlSec - divMin * 60, 2);
let dgtCount := length(substr(TextTime, mssIndex + 1));
if dgtCount < 2 then
rmnSec := rmnSec * 10
"// Build the interval time string";
divMin + ":" + if rmnSec <= 9 then "0" + rmnSec else text(rmnSec) end
thank you so much for taking the time and effort to help me out. I am going to spend some time going through this and see if my elderly brain can grasp hold of what you have written up. I am optimistic, as I can spend hours tinkering around as then I don't have to do other work...ha, ha.
One thing I noticed is that it seems you don't have to create variables ahead of time, rather you just create them as you go? There is no setting of a local, or global variable at the beginning.
I am happy to see that pretty complicated formulas can be written for unique situations. Now, learning how to do that will be an adventure.
I really appreciate your help.
I just tried your formula out and it works as offered. Thank you again. Off to a good start and maybe some fun working with this app....
You're welcome. I really enjoy coding in Ninox and I think it's easy to be productive quickly with the scripting language. Yes, variables can be declared as you go but they do have scope. I'm pretty sure a variable declared inside a loop can't be accessed outside the loop. I suggest you replace this line...
if Miles != 0 then
if Miles != null and Miles != 0 then
You can also add validation and formatting to fields by clicking on "More options" and entering code in "Trigger after update". Here's some code I added to TextTime...
"// Test for colon and add :00 to end of TextTime if only minutes are entered";
if index(TextTime, ":") < 0 then
TextTime := TextTime + ":00"
"// Test colon index for position 0 and add '0' to beginning of TextTime if true";
if index(TextTime, ":") = 0 then
TextTime := "0" + TextTime
"// Test length of string after colon - truncate if greater than 2, add 1 '0' if 1, add 2 '0' if 0";
let secLength := length(substr(TextTime, index(TextTime, ":") + 1));
if secLength > 2 then
TextTime := substr(TextTime, 0, index(TextTime, ":") + 3)
switch secLength do
TextTime := TextTime + "00"
TextTime := TextTime + "0"
Good luck and have fun :)
Thanks for the extras. I hope in time, I can be half as good....:-)
it took me 3 months to convert old Filemaker (4D, Ms Access...) skills into Ninox ones...
Hold on !!
To Pete & Marc,
I'm an old computing brain, as well, with, I'm afraid, bad habits from previous 4D ACI developments…
We did use a lot variables and personalised functions to build a true RDB till we got a end-user interface with menus.
I first thought my experience with 4D would help in Ninox. But I'm feeling more and more lost…
For instance, the FORMAT function is not working the same and I can't get what I was expecting.
And I am still looking for a text function which gives us the length of a caracters' text chain!
I can't either find the explaination of the function INDICE in the 122 pages documentation ?!
We don't even know to which version of the Ninox app this documentation is refering. There is not even publication date on top of it.
And I do agree that it is a big loss of time to ask other people here these simple questions which should be accessible through a good documentation or wiki source.
I admit you, people of Ninox are reactive, and very kind in the way you try to bring your help and skills to us.
But we are more than one to wait for a really structured and documented… documentation !!
Please listen to our demand.
Hold on ! and kind regards