# Tools plugin for everybody

**URL:** <https://forum.servoy.com/t/tools-plugin-for-everybody/980>\
**Category:** Classic Servoy\
**Created:** [January 10, 2004, 12:13am UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980 "2004-01-10T00:13:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [January 10, 2004, 12:13am UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/1 "2004-01-10T00:13:32Z")

</div>

Tools plugin for everybody

Hello forum,

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…

Cheers

BTW you need at least Servoy v2.0b6

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [January 30, 2004, 1:17pm UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/2 "2004-01-30T13:17:20Z")

</div>

Marcel,

EXCELLENT JOB! Inspiring!

I love your idea of the email validation. Would be cool to have a plug-in that did validations (isNumeric, isTextOnly, isInRange, etc.).

Now if only I could find the time… ![:lol:]( "Laughing")

Cheers,

Bob Cusick

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [January 30, 2004, 1:35pm UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/3 "2004-01-30T13:35:30Z")

</div>

Well, this is a glove I have to pick up (is this know in English? In Duch it is “deze handschoen moet ik oppakken”) ![:lol:]( "Laughing")

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [January 30, 2004, 11:51pm UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/4 "2004-01-30T23:51:51Z")

</div>

OK here it is. v2 with 5 new functions:

1. getMaxDay: returns the last day of the given month;
2. isInteger: returns a boolean value, checks a string;
3. isNumber: returns a boolean value after checking a string;  
= localized but will return false when you input thousand seperators…
4. numberFormat: formats the number to the formatString;  
= localized
5. getIT2Be: returns my name, email and GSM ![:lol:]( "Laughing")

And Bob, what exactly do you expect of isInRange and isTextOnly?  
And what further suggestions do you have?

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [January 31, 2004, 12:01am UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/5 "2004-01-31T00:01:11Z")

</div>

> IT2BE:  
> OK here it is. v2 with 5 new functions:
> 
> 1. getMaxDay: returns the last day of the given month;
> 2. isInteger: returns a boolean value, checks a string;
> 3. isNumber: returns a boolean value after checking a string;  
> = localized but will return false when you input thousand seperators…
> 4. numberFormat: formats the number to the formatString;  
> = localized
> 5. getIT2Be: returns my name, email and GSM ![:lol:]( "Laughing")

WOW! EXCELLENT JOB!! ![:o]( "Surprised")

> IT2BE:  
> And Bob, what exactly do you expect of isInRange and isTextOnly?  
> And what further suggestions do you have?

isInRange would return a boolean and would allow you to specify:

isInRange(checkValue, dataType, lowerValue, upperValue)

For Example:  
isInRange(elements.dateField, ‘date’, ‘1/30/2003|M/d/yyyy’, ‘3/20/2003|M/d/yyyy’)

isInRange(elements.numberField, ‘number’, ‘975.12’, ‘1576.4885’)

isInRange(elements.numberField, ‘integer’, ‘1000’, ‘1576’)

The isTextOnly() function would only take the string to compare. So, for example:

var isText = plugins.myplug.isTextOnly(‘This has 1 num in it’);  
//returns FALSE

var isText = plugins.myplug.isTextOnly(‘This has zero nums in it’);  
//returns TRUE

This will help tell if the user entered a number where text only is required. (needs to check if there is a numeric character in the passed string)

Again - GREAT JOB!

Bob

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 1, 2004, 11:14pm UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/6 "2004-02-01T23:14:24Z")

</div>

Here it is, version 3 of the tools plugin. I added the following 4 new methods:

- 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…

- 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

- isTextOnly  
takes a string and returns false if it finds numbers…

- modulus10  
takes a string, filters all numbers and tells you the result of a modulus10 check. Can be used to check a credit card number…

Cheers

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [February 2, 2004, 8:58am UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/7 "2004-02-02T08:58:58Z")

</div>

Nice plugin, well done, one remark:

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 ![:-)]( "Smile") )

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 2, 2004, 9:11am UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/8 "2004-02-02T09:11:30Z")

</div>

Hai Jan,

No problemo. But I personally don’t like very long plugin names. Makes me type more or chances that a line falls off a screen are bigger.

Why not put the name in the .jar file and for the name usage in Servoy just “first-come-first-serve”?

Just a suggestion, otherwise I will upload the renamed version this morning…

BTW do you know how to ‘lock-out’ the .jar from reading the code?

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [February 2, 2004, 9:31am UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/9 "2004-02-02T09:31:25Z")

</div>

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)

To obscurify your code have a look at: [**[u]retroguard[/u]**](http://www.retrologic.com/)

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 2, 2004, 5:46pm UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/10 "2004-02-02T17:46:22Z")

</div>

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

1. getMaxDay  
returns the last day of the given month.

2. getIT2Be  
returns my name, email and GSM ![:lol:]( "Laughing")

(STRING) FORMATTING

1. 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.

2. numberFormat  
formats the (localized) number to the formatString.

3. secondsFormat  
to make a number of seconds a string and the other way around. formatting like HH:mm:ss.

VALIDATION

1. 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.

2. 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.

3. isInteger  
returns a boolean value, checks a string.

4. 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

1. 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.

2. isNumber  
returns a boolean value after checking a string.

- localized but will return false when you input thousand seperators.

1. 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:

plugins.tools = plugins.it2be\_tools  
tools.modulus10 = tools.isModulus10  
tools.validateEmail = tools.isEmail

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

---

<div class="post-metadata">

**Author:** ![Ron](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Ron](https://forum.servoy.com/u/Ron)\
**Post date:** [February 2, 2004, 8:03pm UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/11 "2004-02-02T20:03:21Z")

</div>

Congrats!

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.

TIA

Ron

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 2, 2004, 8:19pm UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/12 "2004-02-02T20:19:03Z")

</div>

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…

Ciao

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [February 2, 2004, 8:22pm UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/13 "2004-02-02T20:22:12Z")

</div>

Well, you also got my compliments… ![:D]( "Very Happy")

I asked one question and next thing I know you have made the function I was looking for! ![:D]( "Very Happy") Great job

Paul

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [February 3, 2004, 10:56am UTC](https://forum.servoy.com/t/tools-plugin-for-everybody/980/14 "2004-02-03T10:56:32Z")

</div>

I love the date ↔ string functions

Keep up the good work!
