Forum Moderators: phranque

Message Too Old, No Replies

Is this possable

         

pcmanauls

1:50 pm on Apr 29, 2004 (gmt 0)

10+ Year Member



I know nothing is inpossable but i have i think a tricky thing to do, any and all help is welcome.

What i want to do is this if someone types a number etc 2A59IZ1DC-00 I want it to separate them like 2A59I Z1 DC-00 and display the information like
2A59I = chipset, Z1 = Manufacturer, DC = The model number -00 is ignored

So the above numbers would work out to this 2A59I stands for the Intel Triton TX chipset, Z1 stands for Zida/Tomato and DC is the model if known.

I am a little stuck how to make this work i have all the information such as chipsets models etc but i want to make it into an easy to use way.

I need a few ideas on how to accomplish this.

dwilson

1:54 pm on Apr 29, 2004 (gmt 0)

10+ Year Member



In what scripting language are you working?

Are the widths of the fields always the same? e.g., is the chipset code always 5 characters long?

txbakers

1:56 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi and welcome to the Webmaster World

What you want to do is very possible, but you'll need some type of scripting language to do it.

In VBScript you would simply do this:

function Split(val)
dim chipset, manu
chipset = left(val,5)
manu = mid(val,6,2)

end function

That would split that for you.

The code is just a sample, it would have to be worked to fit your page.

You can do it in any language, you can also do it on the server if you wanted to.

2A59I = chipset, Z1 = Manufacturer, DC = The model number -00 is ignored

pcmanauls

2:04 pm on Apr 29, 2004 (gmt 0)

10+ Year Member



Thanks for the fast replies.

The numbers will always be in the same format

5x chipset 2x manuafacturer 2x model if known.

As for scripting language, i know a little Perl and PHP by messing with scripts i have purchased but not really enough to build a script from scratch even tho i am eager to learn PHP. Never played with VB.

moltar

3:13 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This should work:

#!/usr/bin/perl

my $proc = '2A59IZ1DC-00';

if ( $proc =~ /^(\w{5})(\w{2})(\w{2})?-\d+$/ ) {
print "Chipset: $1\n";
print "Manufacturer: $2\n";
print "Model: $3\n" if $3;
}

OR

#!/usr/bin/perl

my $proc = '2A59IZ1DC-00';

my ($chipset, $manuf, $model) = $proc =~ m¦^(\w{5})(\w{2})(\w{2})?-\d+$¦;

print "Chipset: $chipset\n";
print "Manufacturer: $manuf\n";
print "Model: $model\n" if $model;

pcmanauls

3:37 pm on Apr 29, 2004 (gmt 0)

10+ Year Member



Sort of understand,

The user will have to type in the numbers so is that statement correct. my $proc = '2A59IZ1DC-00'; because it could be a diffrent number. Also do i have to create some form of database or text file with all the diffrent combinations of chipset and manuafactures.

I really appreciate your help

bedlam

5:40 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hiya,

I'm not sure what you're doing with the information, but one thing you can do is force the user to separate the number into the format you like.

For example, if you were taking phone numbers, you might have a field in your html form for area code and then a field for the 7-digit local number. If you're worried about the user not understanding the two forms, just pre-load the form fields with example digits, or (better) show examples below or above the form fields.

If you can make sure the user enters the information in the form you want it using some method like this it is always better than post-processing it into shape. Note that you should still probably use your scripts to check the information.

-B