Hello Libre Office.
I’m having a bit of a fun time here. This is my first foray into Macros in Libreoffice
I found a page online with a macro someone had built to find House words data of of a wiki page about a song of Ice and Fire and have modified the code they had for my attempt at fetching Magic The Gathering Prices
I have the following function
Public Function FETCHPRICE(sSet as String, sCard as String) as string sURL = "http://mtggoldfish.com/index/" & sSet & "#paper" dim sWords as String oSimpleFileAccess = createUNOService ("com.sun.star.ucb.SimpleFileAccess") oInpDataStream = createUNOService ("com.sun.star.io.TextInputStream") on error goto NoCardFound oInpDataStream.setInputStream(oSimpleFileAccess.openFileRead(sUrl)) on error goto NoCardFound dim delimiters() as long sContent = oInpDataStream.readString(delimiters(), false) lStartPos = instr(1, sContent, "" ) if lStartPos = 0 then Msgbox("Table Not found") FETCHPRICE = "-1.0" exit function end if lEndPos = instr(lStartPos, sContent, "
When I run it with Known values Like
=FETCHPRICE(“RAV”,“Circu, Dimir Lobotomist”)
it either Errors (which I assume is a result of me hitting thier page too frequently and in future revisions I can correct for)
or it Gives me back a BLANK CELL
I’ve inserted Breakpoints and put a watch on the sPrice Variable which is indeed a string variable with the correct price value in it when it is returns
Now the strange part is
When I open the Fuction wizard and enter the function it shows in the result window the correct resulting price.
Click OK in there to make the formula insert into the cell and it Either gives me “Error Finding Card” or gives me a Blank cell
I tried several things to remedy this
such as Returning “” & sPrice
Changing the function so it returns Double (and changing the “-1.0” returns to -1.0
But that didn’t work because when I tried to cDbl(sPrice) it didn’t like it It said Invalid Procedure call
I saw that Cdbl to go from String to Double needs to be cDbl(“12345”) format so I tried making it cdbl("""" & sPrice & “”"")
to concatinate some "'s around it
But no dice
I tried setting sPrice to "Price is: " & sPrice on the line before I returned it but no dice I get "Price is: "
When I alter the function so that the return value is a hard coded string It returns fine
When I return sPrice & “KAKAW”
I get “KAKAW” in the cell
But in all cases my Function wizard displays things like
Price is: 2.30
etc etc depending on which one of my failed fixes is or is not applied
yet the cell itself will not display the 2.30
As well we know from my breakpoints and watches (and from Msgbox(sPrice)) that sPrice is indeed containing the value 2.30 which is the correct price for “Circu, Dimir Lobotomist” as of this posting
Any help you have would be appreciated as google has failed me.