New topic: 

Unable to call a Function properly

<http://forums.realsoftware.com/viewtopic.php?t=30529>

       Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic         Author  
Message       dutch_kuykendall           Post subject: Unable to call a 
Function properlyPosted: Fri Oct 16, 2009 10:28 pm                        
Joined: Fri Oct 16, 2009 9:46 pm
Posts: 1
Location: Blue Ridge, Texas              Window1 has a button called Utilities, 
when clicked, it launches Window2
(or it wood if I wasn't getting an error)
Window2 has a button called Convert Whealed File, when clicked it would
call a Function called “Function Paired(aTemp As String) As 
String"[code][/code]
The simplified code for that function is as follows:

  Dim PairCounter As Integer

  PairCounter = 3

  Paired = Str(PairCounter)

The problem is with Window2 (I assume):
  Dim aTemp(-1) As String

  Dim Pairs As String

  Dim TestVal As Integer


// used this way I get an "You must use the value returned by this function" 
error

  'Paired(aTemp,Pairs)

// used this way I get a "Parameters are not compatible with this function" 
error

  'Pairs = Paired(aTemp)

//used this way I get a "Parameters are not compatible with this function" error

  'TestVal = Cdbl(Paired(aTemp)

//used this way I get a "This method requires fewer paramiters than were 
passed" error

  'TestVal = CDbl(Paired(aTemp, Pairs)

//used this way I get a "This method requires fewer paramiters than were 
passed" error

  'Call Paired(aTemp,Pairs)

//used this way I get a "Parameters are not compatible with this function" error

  'Call Paired(aTemp)

// used this way I get an "You must use the value returned by this function" 
error

  Paired aTemp,Pairs

  TestVal – Cdbl(Pairs)

I'm running REALbasic 2009 Rev. 4 on Linux Ubuntu 9.04   
                            Top                npalardy           Post subject: 
Re: Unable to call a Function properlyPosted: Fri Oct 16, 2009 11:35 pm         
               
Joined: Sat Dec 24, 2005 8:18 pm
Posts: 5328
Location: Canada, Alberta, Near Red Deer              dutch_kuykendall 
wrote:Code:Function Paired(aTemp As String) As String

The problem is with Window2 (I assume):
  Dim aTemp(-1) As String

  Dim Pairs As String

  Dim TestVal As Integer


// used this way I get an "You must use the value returned by this function" 
error
  'Paired(aTemp,Pairs)


Closely examine your function
It takes ONE parameter and returns one value - a string
You're trying to pass two values - aTemp and Pairs
And not putting the return value anywhere

dutch_kuykendall wrote:// used this way I get a "Parameters are not compatible 
with this function" error
  'Pairs = Paired(aTemp)

This is closer except aTemp is an ARRAY of strings not a single string
something like Call Paired(aTemp(0)) perhaps 

dutch_kuykendall wrote://used this way I get a "Parameters are not compatible 
with this function" error
  'TestVal = Cdbl(Paired(aTemp)

This would work except that it again tries to pass an array instead of a single 
string

dutch_kuykendall wrote://used this way I get a "This method requires fewer 
paramiters than were passed" error
  'TestVal = CDbl(Paired(aTemp, Pairs)

Right ... your passing two and it expects one

dutch_kuykendall wrote://used this way I get a "This method requires fewer 
paramiters than were passed" error
  'Call Paired(aTemp,Pairs)

Right ... your passing two and it expects one

dutch_kuykendall wrote://used this way I get a "Parameters are not compatible 
with this function" error
  'Call Paired(aTemp)

This is closer except aTemp is an ARRAY of strings not a single string
It would allow you to ignore the return value
something like Call Paired(aTemp(0)) perhaps 

dutch_kuykendall wrote:// used this way I get an "You must use the value 
returned by this function" error
  Paired aTemp,Pairs
  TestVal – Cdbl(Pairs)


In order to define a function that returns a value
Try
Code:Function Paired(aTemp As String) As Integer
  Dim PairCounter As Integer
  PairCounter = 3
  return PairCounter
end function



then call it like

TempVal = Paired( pairs ) // pairs is a simple string  - not an array so it 
works     
_________________
My web site Great White Software
RBLibrary.com REALbasic learning  
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to