Just for the fun of it I wanted to be the first (I hope or else one of the first) to give you the taste of a homebrew Plugin for Servoy.
Not too much but for me very convenient with three methods:
dateFormat: very much like the Java dateFormat class to convert a date to a string and the other way around with (or without) a formatting string;
secondsFormat: to make a number of seconds a string formatted like HH:mm:ss
validateEmail: based on a method I posted earlier on this forum now as a method in this plugin. It takes a string with one or more email adresses and checks if the format is right.
The reason I made them (initially for my own use) was that I needed to do the same calculation over and over again on different forms. However you can’t reach a method via a calculation field.
I didn’t want to ask for a feature since the guys at Servoy are already busy enough and to trigger myself to learn Java and making a Plugin.
The result is attached. Just drop it in your plugins folder and restart Servoy.
Feel free to use it and distribute it.
Any suggestions? Please let me know!
Any bugs? Please tell me!
Any new features needed? Please ask me?
Any questions? I don’t know if we are allowed to use this forum for it but for now: Ask me!
Happpy? Don’t hasitate to share it with me…
We are setting up a plugin registry (web page) to list all available plugins and prevent JavaScript plugin name collisions in future.
On that page will suggest to use names like “Company name” abbreviation followed with “_” and the goal of the plugin (and also name the jar that way)
So a nice JavaScript name for your plugin whould be:
“it2be_tools” packed in a file it2be_tools.jar
You might consider updating your plugin (before its widely used), also seen the fact your name get more exposure (it’s in all the scripts )
Well it a suggestion, not a requirement, good practice like Java code package naming…
Most people will use “move” code anyway or use code completion (CTRL-SPACE), so typing will not be the problem.
At least name your plugin that way.
Tip: do only pack the files needed in the jar (.class/.gif)
Version 4 of the Tools plugin is now renamed to it2be_tools upon request of Servoy.
PLEASE ONLY USE THIS RELEASE AND DELETE THE OLD ONE…
I optimized some code, corrected an error in the isModulus10 function and renamed validateEmail into isEmail and modulus10 into isModulus10…
The tools plugin holds the following twelve functions:
CALCULATION
getMaxDay
returns the last day of the given month.
getIT2Be
returns my name, email and GSM
(STRING) FORMATTING
dateFormat
very much like the Java dateFormat class to convert a date to a string and the other way around with (or without) a formatting string.
numberFormat
formats the (localized) number to the formatString.
secondsFormat
to make a number of seconds a string and the other way around. formatting like HH:mm:ss.
VALIDATION
isEmail
based on a method I posted earlier on this forum now available in this plugin. It takes a string with one or more email adresses and checks if the format is correct.
isExpired
takes a year, month and (optional) day and returns a boolean when expired. Can be used to check the expiration date of a credit card.
isInteger
returns a boolean value, checks a string.
isInRange
takes dates, numbers/integers and strings and returns true or false.
dates: dates need to be set with new Date() not a db timestamp
string: there is an option to be set to true if you want to ignore cases
isModulus10
takes a string, filters all numbers and tells you the result of a modulus10 check. Can be used to check a credit card number.
isNumber
returns a boolean value after checking a string.
localized but will return false when you input thousand seperators.
isTextOnly
takes a string and returns false if it finds numbers.
The result is attached. Just drop it in your plugins folder and restart Servoy.
REMARK: When you used my old plugin please do a global search and replace for:
Feel free to use it and distribute it but give me credit for it.
The plugin is provided M-^Qas isM-^R and I can not take any responsibility for the way it behaves or works
Any suggestions? Please let me know!
Any bugs? Please tell me!
Any new features needed? Please ask me?
Any questions? I don’t know if we are allowed to use this forum for it but for now: Ask me!
Happpy? Don’t hesitate to share it with me…
Cheers
BTW the tools plugin is written to work with Servoy v2M-^E
This is a great plugin Marcel!
Especially taking into consideration that untill recently you were a newby to Java and Javascripting.
I did’nt test all features but the I can’t get the secondsFormat working.
I set the variable to a datefield.
I get an error saying: ‘seconds2time is not a function’
I assume I do something wrong, can you give me a script example?
BTW maybe it is a good ID to give a little bit more info in your sample info.
Oh, I am sorry. seconds2time is the first name I gave secondsFormat and forgot to update it in the tooltip. So change the example to secondsFormat, input an integer and it will work… Or just transfer the function without example.
As for the examples. I tried to make a compromise between the amount of work an self expanatory examples… Not enough so it seems.
I will try to make this a little better in a next version…
Thanks for the compliments. Keep complimenting and challenging me and I will proceed with the plugin…