Normal Topic [Solved] Function error.. (Read 685 times)
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
[Solved] Function error..
Jan 28th, 2008 at 12:47pm
Print Post Print Post  
[color=#ff0000][b][size=16]Solution: If a Function does not include a return statement, it will throw an error.[/size][/b][/color]

Hello!

i want to use a Function Phone() in MyFunction.sbas bat a get sBasic error:

Hier is the crappity smacktion Phone:

:On Global Code
stat sElementLength as int

:ON Element immediate Change (Phone Field)
ThisElement = PHONE(ThisElement)

The Function Phone() in MyFunction.sbas:

Function PHONE(val as String) as String
// Phone w/Ext template in the format of (###) ###-####  Ext-#####
var vPos as int
var vStr as string

vPos = @CursorPosition(ThisElement)
vStr = @Num(ThisElement)

if vPos = 1 and (@Len(vStr) > sElementLength)
     vPos = 2
if vPos = 5 and (@Len(vStr) > sElementLength)
     vPos = 7
if vPos = 10 and (@Len(vStr) > sElementLength)
     vPos = 11
if vPos = 15 and (@Len(vStr) > sElementLength)
     vPos = 21

if @Len(vStr) > 0
     vStr = "(" + vStr
if @Len(vStr) > 4
     vStr = @Lt(vStr, 4) + ") " + @Mid(vStr, 5, 12)
if @Len(vStr) > 9
     vStr = @Lt(vStr, 9) + "-" + @Mid(vStr, 10, 9)
if @Len(vStr) > 14
     vStr = @Lt(vStr, 14) + "  Ext-" + @Mid(vStr, 15, 5)

ThisElement = vStr

CursorPosition(ThisElement, vPos)

sElementLength = @Len(@Num(vStr))

End Function


Thank you for the Help

Dr. Belhareth
« Last Edit: Jan 29th, 2008 at 1:28pm by Hammer »  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Function error..
Reply #1 - Jan 28th, 2008 at 12:58pm
Print Post Print Post  
[quote author=Amor link=1201524456/0#0 date=1201524456]
i want to use a Function Phone() in MyFunction.sbas bat a get sBasic error:[/quote]
What SBasic error do you get?

  

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


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: Function error..
Reply #2 - Jan 28th, 2008 at 1:37pm
Print Post Print Post  
Hello Erika,

Every Modification in Field Phone a get Error:

"A runtime SBASIC error ha occured. Please close this form and repair the condition before continuing."

Thanks.
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Function error..
Reply #3 - Jan 28th, 2008 at 1:47pm
Print Post Print Post  
Amor,

Your function does not return anything. You need to either make it a subroutine or return a value.
  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Function error..
Reply #4 - Jan 28th, 2008 at 8:13pm
Print Post Print Post  
Ah, looks like you're making use of my Interactive Data Entry Templates (Inside Sesame, May 2006).

Nice to see that it's being put to use. Smiley
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: Function error..
Reply #5 - Jan 29th, 2008 at 8:57am
Print Post Print Post  
Hello Erika,

All a need to do is to add the Return value and load the function in the Element Exit Mode.

Carl : Thank you very much for the Artikel in insidesesame.

Thanks for all your help.
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged