Calling a Subprocess from a Function

Creating a macro - Writing a Script - Using the API

Calling a Subprocess from a Function

Postby evergreen1231 » Fri May 12, 2017 7:46 am

I would like to call a sub process from a function since I want to check values through a loop and return the the largest value to the function. I think I have a small program that should do this, but I'm getting an error that reads:
Code: Select all   Expand viewCollapse view
BASIC runtime error. Argument is not optional.
OO highlights the place where I set the Function's Name equal to the output of the subprocess.

Below is my code...
Code: Select all   Expand viewCollapse view
   function FIND_VARIED_MAXIMUM( fromDate as long, toDate as long, station as integer, point as integer, pointType as string, attrib as string, historialAttribute as string )
   FIND_VARIED_MAXIMUM = findMax(fromDate, toDate, station, point, pointType, attrib, historialAttribute)
end function

sub findMax(theFromDate as long, theToDate as long, theStation as integer, thePoint as integer, thePointType as integer, theAttribute as string, theHistoricalValue as string)
   dim i as integer
   dim temp as variant
   dim tempTemp as variant
   dim teMinutes as integer
   tenMinutes = 600
   dim time as long
   time = 00000000
   for i = theFromDate to theToDate step tenMinutes
      tempTemp = myaddin.CUST(time, station, category, point, pointType, historicalAttribute, attrib)
      if tempTemp > temp then
         temp = tempTemp
      end if
   next i
end sub


Any help would be appreciated. I have searched with little success.
OpenOffice 3 on RHEL5
evergreen1231
 
Posts: 2
Joined: Fri May 12, 2017 7:34 am

Re: Calling a Subprocess from a Function

Postby JeJe » Fri May 12, 2017 11:29 pm

Your PointType is a string in the first function, an integer in the second.

Are you trying to run it without calling FIND_VARIED_MAXIMUM from elsewhere?

This doesn't give that error.

Code: Select all   Expand viewCollapse view
sub tmp
res = FIND_VARIED_MAXIMUM(a,b,c,d,e,f,g)
end sub

Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 114
Joined: Wed Mar 09, 2016 2:40 pm

Re: Calling a Subprocess from a Function

Postby evergreen1231 » Tue May 16, 2017 5:15 pm

JeJe wrote:Your PointType is a string in the first function, an integer in the second.

Are you trying to run it without calling FIND_VARIED_MAXIMUM from elsewhere?

This doesn't give that error.

Code: Select all   Expand viewCollapse view
sub tmp
res = FIND_VARIED_MAXIMUM(a,b,c,d,e,f,g)
end sub


I see what you're saying about the type miss-match, but I'm afraid I don't see where your code snippet could be used. Could you elaborate?
OpenOffice 3 on RHEL5
evergreen1231
 
Posts: 2
Joined: Fri May 12, 2017 7:34 am

Re: Calling a Subprocess from a Function

Postby JeJe » Tue May 16, 2017 7:08 pm

If I run sub tmp it calls FIND_VARIED_MAXIMUM fine. There is no error until the line

tempTemp = myaddin.CUST(time, station, category, point, pointType, historicalAttribute, attrib)

As you haven't provided myaddin.CUST sub I can't help you with that.

Your FIND_VARIED_MAXIMUM doesn't do anything except call the function findMax so is superfluous.

That's all I can say here.

If you're trying to run the function FIND_VARIED_MAXIMUM without calling it from another sub like the one I've created called tmp - its not going to work - that's what you need to do.
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 114
Joined: Wed Mar 09, 2016 2:40 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: Lupp and 11 guests