Calling a Subprocess from a Function

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
evergreen1231
Posts: 2
Joined: Fri May 12, 2017 7:34 am

Calling a Subprocess from a Function

Post by evergreen1231 »

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

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

	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
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: Calling a Subprocess from a Function

Post by JeJe »

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

sub tmp
res = FIND_VARIED_MAXIMUM(a,b,c,d,e,f,g)
end sub

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
evergreen1231
Posts: 2
Joined: Fri May 12, 2017 7:34 am

Re: Calling a Subprocess from a Function

Post by evergreen1231 »

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

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
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: Calling a Subprocess from a Function

Post by JeJe »

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.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply