Normal Topic Programming Question with Importing (Read 1449 times)
Dnolan
Member
*
Offline


No personal text

Posts: 20
Joined: Feb 27th, 2004
Programming Question with Importing
Jun 11th, 2004 at 1:59pm
Print Post Print Post  
I imported a database from Q&A into my new Sesame database. However through the transfer the Phone # and Fax # files got messed up.

The numbers transferred over w/out any () or - in the #. I tried doing a mass update with the code
Code
Select All
Phone #= "(" + @Left(Phone #, 3) + ")" + @Mid(Phone #,4,3) + "-" @Right(Phone #, 4)  


and it didn't work, somehow, all it did was put double parenthesis in the front and it deleted the whole mid section.

I want to change it so that the numbers look like (555)555-5555. I don't know how to do this. I can either do something with importing them one more time. Or I can do another Mass Update .

If someone could help that would be wonderful. Thank you all for your help!!!
  
Back to top
 
IP Logged
 
Justin_ICC
Junior Member
**
Offline



Posts: 95
Joined: Feb 5th, 2004
Re: Programming Question with Importing
Reply #1 - Jun 11th, 2004 at 3:05pm
Print Post Print Post  
Is the type of the Phone # LE number or text? If it is a number than that code will not work properly. Sesame uses strong typing and it will not always work correctly if you do not explicitly convert types.
try this:
Code
Select All
(text LE) = "(" + @Left(@STR(Phone #), 3) + ")" + @Mid((@STR(Phone #), 4,3) + "-" @Right((@STR(Phone #), 4)
 

  
Back to top
 
IP Logged
 
Dnolan
Member
*
Offline


No personal text

Posts: 20
Joined: Feb 27th, 2004
Re: Programming Question with Importing
Reply #2 - Jun 14th, 2004 at 3:44pm
Print Post Print Post  
I tried the code, but it says "Statement or End-of-File expected." so something is wrong. I did a mass-update with that code on the Phone # field. Maybe it was me, I am really lost here and don't understand why this isn't working. Help!
Thanks!!  Smiley
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Programming Question with Importing
Reply #3 - Jun 14th, 2004 at 4:05pm
Print Post Print Post  
Hey guys,

While you're working this out, the code you are posting is missing a plus sign (+) before @Right...

Smiley
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Programming Question with Importing
Reply #4 - Jun 14th, 2004 at 6:56pm
Print Post Print Post  
The above will work with Mass Update and reformat the existing records as per your need. However, when you enter the phone number while adding new records, you want to have it reformat as per your need. The following code will help you doing just that. I believe this code was offered by Bob Scott in the earlier posting.

// Formats Telephone Number

var vHPhone as String      
var vNewHPhone As String  
var vhphonecount  
var vhpnentered

Vhpnentered = @num(HomePhone)
// Writeln(Vhpnentered)  
 
vhphonecount = @num(@len(vhpnentered))
//writeln(vhphonecount)

If vhphonecount = "10"  


{
vHPhone = @Num(HomePhone)  
vNewHPhone = "(" + @Left(vHPhone, 3) + ") " + @Mid(vHPhone, 4, 3) + "-" + @Right(vHPhone, 4)  
HomePhone = vNewHPhone  
}
else
{
Writeln("The Telephone Number needs to be Exactly 10 Digits")
  Writeln("The numbers you entered: " + @num(Homephone))
  Writeln("is : " + Vhphonecount + " Digits Please check Home Telephone and Re-enter")
 
}  
  
Back to top
 
IP Logged
 
Dnolan
Member
*
Offline


No personal text

Posts: 20
Joined: Feb 27th, 2004
Re: Programming Question with Importing
Reply #5 - Jun 15th, 2004 at 1:04pm
Print Post Print Post  
In the error it replaces Phone # with (LENID000012).  ???

Code
Select All
 Error while parsing module "Phone #":
Statement or End-Of-File expected.
Line 1, position 1 : (
(text LE) = "(" + @Left((@STR(LENID000012), 3) + ")" + @Mid((@STR(LENID0000...
   ^ 



What is that? And why does that happen? Do I have it labeled wrong or something?

I enter the code into the mass update in the Phone # field and it won't even let me execute it because of this error.

I have a feeling I am doing something wrong here. If someone could help that would be great.

Thanks!!
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Programming Question with Importing
Reply #6 - Jun 15th, 2004 at 1:12pm
Print Post Print Post  
<interjecting some technical info to help while you work on this>
The LENID... stuff does not mean you've done something wrong.  We allow certain characters in element names, like spaces, by quietly legalizing the element name. You are seeing that legalized name in the error message. This is not, in itself, the error, and you don't need to worry about it.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Programming Question with Importing
Reply #7 - Jun 15th, 2004 at 1:13pm
Print Post Print Post  
PhoneNumber = "(" + @Left(@STR(PhoneNumber), 3) + ")" + @Mid((@STR(PhoneNumber), 4,3) + "-"  + @Right(@STR(PhoneNumber), 4)

Phone # is not valid LE name. "#" is not allowed in LE name.  Label can contain this character but not the underlying LE.
« Last Edit: Jun 15th, 2004 at 7:08pm by Bharat_Naik »  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Programming Question with Importing
Reply #8 - Jun 15th, 2004 at 6:57pm
Print Post Print Post  
DNolan,

You have a bunch of mismatched parentheses. The error you are seeing indicates a syntax error in your code. Here is a version that will compile:

PhoneNumber = "(" + @Left(@STR(PhoneNumber), 3) + ")" + @Mid(@STR(PhoneNumber), 4, 3) + "-"  + @Right(@STR(PhoneNumber), 4)
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Dnolan
Member
*
Offline


No personal text

Posts: 20
Joined: Feb 27th, 2004
Re: Programming Question with Importing
Reply #9 - Jun 16th, 2004 at 1:37pm
Print Post Print Post  
THANK YOU SO MUCH!! The code works great and thank you so much. Much appreciated. You guys are great! Smiley

DNolan
  
Back to top
 
IP Logged