Tools plugin 1.7 (improved zip & unzip)

Questions and answers on developing, deploying and using plugins and JavaBeans

Tools plugin 1.7 (improved zip & unzip)

Postby IT2Be » Wed Mar 24, 2004 1:45 am

The very first plugin for Servoy, Tools now reached it's 7th revision.

I improved the zip and unzip classes to work with folders also and I dropped the DES encryption. The encryption functions have been moved to my latest plugin Cryptor.

Have fun with it and check out my second (Splash) plugin to show a splash screen and my third (Cryptor) plugin...

The tools plugin now holds the following FIFTEEN functions:

FILES
1.zip
zip a (single) file and a folder.

2.unzip
unzip a file, a group of files and folders. REMARK: mac OS X users wonM-^Rt be able to resolve a zipped application with this unzip utility (yet). When you unzip a file or folder to a destination with a file or folder with the same name the file or folder will be numbered. The numbering will be checked also.

CALCULATION
3. getMaxDay
returns the last day of the given month.

4. getIT2Be
returns my name, email and GSM.

(STRING) FORMATTING
5. 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.

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

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

8.Mirror
reverse a string M-^QmirrorStringM-^R into M-^QgnirtSrorrimM-^R.

VALIDATION
9. 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.

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

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

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

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

14. isNumber
returns a boolean value after checking a string.
* localized but will return false when you input thousand seperators.

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

Feel free to use it and distribute it but give me credit for it.
The plugin is free, provided M-^Qas isM-^R and I can not take any responsibility for the way it behaves or works.

And I would really like some feedback on (most) wanted functions. Maybe in the direction of validation...

Cheers
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby wgknowles » Fri Jun 11, 2004 12:08 am

Could you do a Phone # format validation/standardization?

eg (123) 456-7890

A little more ambitious, using an online database;
Maybe a Zip Code / city / area code crossreference?
OmniPresent Systems LLC
Home & Business Automation Specialists
Digital Video Surveillance (CCTV)
Access Control Solutions (Smart Card, Proximity, RFID)
wgknowles at gmail.com
wgknowles
 
Posts: 92
Joined: Wed Apr 07, 2004 12:11 am

Postby pbakker » Fri Jun 11, 2004 9:40 am

I think you're moving into the area of address validation here...

I'm working on a Dynamic WebService Invoker plugin for Servoy.

On the internet (for example: www.xmethods.com) you can find many webservices (some for free, some for charge) and also many address validation functions (I've seen dutch and UK adresscheck, but probably there are functions for other countries as well).

One of these functions, together with the plugin I'm writing probably gives you the functionallity you need.

I hope to release a beta version of the plugin in about a week or so

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Clive Sanders » Tue Jun 15, 2004 10:44 am

We use AddressWizard quite extensively on some of our web sites for addresses in the UK. Will we able to use your new plug in with this service?

http://www.addresswizard.co.uk
Clive Sanders
 
Posts: 92
Joined: Mon Jan 26, 2004 7:42 pm

Postby pbakker » Tue Jun 15, 2004 11:04 am

I had a look at the website and it looks to be a webservice implementation, but it doesn't say so.

If it is a webservice implementation, you sure can implement it into Servoy with my plugin. BTW, the plugin is posted on the forum since yesterday.

On http://www.addresswizard.co.uk I see you can register and get some samplecode for implementation in HTML. If you have that samplecode and it is a WebService, then in that samplecode there should be a location (internet address). Use that location as the first parameter for the getWSInfo function of my plugin, and have a look at the result.

With the provided samples in the plugin, you should be able to figure out how to implement it into your Servoy solution.

If needed, send me the samplecode and I'll have a look at it.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Clive Sanders » Tue Jun 15, 2004 11:15 am

Having registered with addresswizard, this is what you receive back to include in the relevant web page:

Code: Select all
<!-- Start of AddressWizard HTML                                         -->
<!--                                                                     -->
<!-- This code adds a new postcode field to your address form that       -->
<!-- allows the user to search for a full postal address.                -->
<!--                                                                     -->
<!-- 1. Include this code inside your address form, before the first     -->
<!--    address field, but after the <FORM ...> tag.                     -->
<!--                                                                     -->
<!-- 2. Customize "ReturnAddress(asAddressLines)" to return data into    -->
<!--    your form fields. You will need to change occurances of          -->
<!--    "YourAddressForm" to the name of your form and change the form   -->
<!--    field names to the names of your address fields. You can also    -->
<!--    use this function to append address lines together if you have   -->
<!--    less than seven address lines in your address form.              -->
<!--                                                                     -->
<!--    NOTE: JavaScript is case sensitive, please make sure the case    -->
<!--          of the form and field names match that actual names.       -->
 
   <SCRIPT
   src="http://www.addresswizard.co.uk/bin/script2.cgi?686F6E616E2E7263693340706F7369746976652D7468696E6B696E672E636F2E756B">
   </SCRIPT>
   <SCRIPT>
     <!--
     function SetAddressField(formField, addressLine)
     {
       formField.value = addressLine;
     }
     function AppendAddressField(formField, addressLine)
     {
       if ((formField.value.length > 0) && (addressLine.length > 0))
         formField.value = formField.value + ', ' + addressLine;
       else
         formField.value = formField.value + addressLine;
     }
     /* This function is called from the script2.cgi Javascript, which
        passes in an array of strings, containing the seven lines of
        the customer address. You may modify this function if you
        want to change the format of the address form below.       */
     function ReturnAddress(asAddressLines)
     {
       SetAddressField(document.YourAddressForm.Address1, asAddressLines[0]);
       AppendAddressField(document.YourAddressForm.Address1, asAddressLines[1]);
       SetAddressField(document.YourAddressForm.Address2, asAddressLines[2]);
       AppendAddressField(document.YourAddressForm.Address2, asAddressLines[3]);
       SetAddressField(document.YourAddressForm.Town, asAddressLines[4]);
       SetAddressField(document.YourAddressForm.County, asAddressLines[5]);
       SetAddressField(document.YourAddressForm.Postcode, asAddressLines[6]);
       SetAddressField(document.YourAddressForm.Premise, asAddressLines[7]);
     }
     // -->
   </SCRIPT>
 
  <!-- This is the new postcode field, where users will enter the          -->
  <!-- postcode they want to search for.                                   -->
    Postcode
    <input type=text name=searchpostcode size=10>
 
  <!-- This is the Find Address button, which users press to search for    -->
  <!-- the full postal address.                                            -->
 
  <!-- 3. Change YourAddressForm in the lines below to the name of your       -->
  <!--    address form. Use the same capitalisation as in the FORM tag.    -->
 
    <input type=button
           name=find
           value="Find Address"
           onclick="InvokeAddressWizard('',
                    document.YourAddressForm.searchpostcode.value)">
  <!-- End of AddressWizard HTML                                           
Clive Sanders
 
Posts: 92
Joined: Mon Jan 26, 2004 7:42 pm

Postby pbakker » Tue Jun 15, 2004 11:29 am

I've checked the "http://www.addresswizard.co.uk/bin/script2.cgi?686F6E616E2E7263693340706F7369746976652D7468696E6B696E672E636F2E756B" string, it's not directly a webservice. This location points to another script on the website and that script then calls another script...

I cannot trace it further, because then you run into authentication issues.

I would suggest you contact this company, to see if they can provide you with the webservice information, if it's a webservice. Trying to track it down, I was provided with the following address to send questions to: wizard@addresswizard.co.uk

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Clive Sanders » Tue Jun 15, 2004 11:47 am

Thanks for that, I have sent an email to addresswizard to see if they can help.

Meanwhile, do you have any other suggestions for an address lookup web service for the UK that would work with your plugin.

Thanks
Clive Sanders
 
Posts: 92
Joined: Mon Jan 26, 2004 7:42 pm

Postby pbakker » Tue Jun 15, 2004 12:04 pm

I hope they can provide you with the needed info. Please keep us posted on it, 'cause I'd like to know how it evolves...

A good source to find WebServices is www.xmethods.com. I looked there quickly and found a WebService that takes a UK zipcode as input and returns all addresses that go with it. The location of the webservice is: http://www.lixusnet.com/lixusnet/AddFinder.jws?wsdl

Give that as input for the getWSInfo and you'll see that the methodname = process and that it takes one string as input.

If you look at www.xmethods.com more thorougly, you'll probably find more WebServices for addressvalidation in the UK.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Clive Sanders » Tue Jun 15, 2004 12:44 pm

We have standard address fields:
Premises
AddressLine1
AddressLine2
AddressLine3
City
County
Postcode
Country

I have had a quick look at the Lixus version and it seems to return an address string, with each address part separated by a comma, but it doesn't seem to have a fixed number of address items. How will I be able to place the correct part in the relevant field, i.e. put the first line of the address in addressline1, the city into city etc. etc.
Clive Sanders
 
Posts: 92
Joined: Mon Jan 26, 2004 7:42 pm

Postby pbakker » Tue Jun 15, 2004 1:20 pm

If the service really gives back an unstructured result, it's virtually impossible to interpret it correctly. If this is the case, it would be a poorly designed webservice.

Are you sure it's unstructured as you say?

Could you post the return string where you see the problem?

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Clive Sanders » Tue Jun 15, 2004 1:48 pm

I typed in the postcode of BN27 1EX, and got the following results:
Code: Select all
Array processReturn
{
   item[0] = 12, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[1] = 14, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[2] = 15, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[3] = 16, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[4] = 17, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[5] = 18, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[6] = 19, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[7] = 20, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[8] = 21, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[9] = 22, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[10] = 23, Hawthylands Road, HAILSHAM, BN27 1EX,
   item[11] = 25, Hawthylands Road, HAILSHAM, BN27 1EX
}

I have to say though, that the service is a bit flaky, a couple of times I got a server error.
I also tried the only other service that I could find from websrvice.net and that only checks the first part of the postcode which is very useful.
Clive Sanders
 
Posts: 92
Joined: Mon Jan 26, 2004 7:42 pm

Postby pbakker » Tue Jun 15, 2004 2:40 pm

It looks to me that the format is structured. Every address has 4 entries, all comma separated.

So i asume your problem lies in the fact that you have more fields to fill in your DB than this service given as result. There's not much that can be done about that, since this is whatever the service provides.

I did a Google search on webservice addressvalidation UK and found the following site: http://undergroundlondon.com/antimega/b ... 00106.html
This website has a link to http://www.webservicex.net/WS/default.aspx, which has information on several webservices for address validation.

Maybe one of them does what you're looking for.

When doing a getWSInfo in Servoy on 'http://www.webservicex.net/uklocation.asmx?WSDL' I discovered a little bug in the plugin for Servoy. In the case of multiple methods at one webservice location, the info returned by the plugin is only one method, instead of all methods. I'll fix this and release beta3, probably somewhere tomorrow.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Clive Sanders » Tue Jun 15, 2004 2:52 pm

Unless I have missed something, this service only check the first part of the postcode, and only returns the town/county/psotcode.

What we need is a full postal address lookup. The user may not know the county or town, or it could be wrong. So, the requirement is as addresswizard, i.e. put in the postcode and it returns the whole of the address right down to the letterbox.
Clive Sanders
 
Posts: 92
Joined: Mon Jan 26, 2004 7:42 pm

Postby pbakker » Tue Jun 15, 2004 3:04 pm

I didn't look into the details of the webservices they offer. All i know is that there are many around, all providing a slightly different service.

Since you seem to be happy with what the addresswizard offers, I think your best option is to await a reply from them, to see if they have their service as a webservice. If they are in way looking towards the future, they will, because webservice is the way of the future to exchange data between servers.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Next

Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 44 guests