Error assigning value to Variant variable

I have an automation that returns string. When I try to assign this into a variable of the type variant, I get the following error: The length of the text string exceeds the size of the string buffer. This is related to the size of the input string from the automation. Bjarni Thor Bjarnason Software Development Landsteinar Iceland

evaluate(vVariant,format(automation.ReturnValue));

Hi bthor, We had the same problem with that text buffer. The problem is that the length of internal Navision text buffer is 250 characters. So we came to the BLOB fields: CALCFIELDS(“Destination Field”); “Destination Field”.CREATEOUTSTREAM(OStreamVar); WHILE AutomationBSTR.GetNextStringPortion(TextBuffer,MAXSTRLEN(TextBuffer)) > 0 DO OStreamVar.WRITETEXT(TextBuffer); I don’t now is it suitable in your situation but that is the way we’ve got round that buffer. /DMC

Thank you for your answers, but these solutions do not work for me. Using the Evaluate(vVariant,Format(automation.ReturnValue)); Gives the same error. Even when I try to do: Evaluate(vVariant,Format(automation.ReturnValue,100)); I tried using the blob and instream, but it does not work either. When I assign the data to the intream I get the message: A variable was expected. For example: MyVar Customer.Name See code example RecVar.GET; RecVar.BlobField.CREATEINSTREAM(InStreamVar); InStreamVar.READ(SigSign.SigString); Bjarni Thor Bjarnason Software Development Landsteinar Iceland

vString := format(automation.ReturnValue); It workd with SQL conection via ADO in NavisionDb Server. Automation return variant values.

I am facing the same problem with “The length of the text string exceeds the size of the string buffer.” I was trying to integrate FedEx API into Navision so that we can ship or track a package through Navision. Upon shipping a package, FedEx will send back a string of text containing confirmation information and tracking number. This information is sent back when we call this method: FedExAPI.FedExAPITransaction(2016, TempSendBuf, ServerURL, 8190) //(FedExAPI is an automation object) I know that eventhough we can declare a variable of Text type with the maximum size of 1024, Navision cannot handle more than 250 characters during the reading/writing process (sorry for lack of better words) So i tried using the BLOB field to stream the value (returned by FedEx) out to an external Text File… TempText.CALCFIELDS(TempString); //TempString is a BLOB field in the TempText table TempText.TempString.CREATEOUTSTREAM(ReturnBufStreamOutObj); ReturnBufStreamOutObj.WRITETEXT( FedExAPI.FedExAPITransaction(2016, TempSendBuf, ServerURL, 8190)); But i got “The length of the text string exceeds the size of the string buffer.” I also tried this: ReturnBufStreamOutObj.WRITETEXT( FedExAPI.FedExAPITransaction(2016, TempSendBuf, ServerURL, 8190), 100); thinking maybe i can read the first 100 characters but i got the same error message. I noticed what DMC said about using this: AutomationBSTR.GetNextStringPortion() function But the FedExAPI object has only one method:FedExAPITransaction() which returns the whole string…but no other methods to manipulate strings. I very much appreciate any suggestion and help here ! Thanks Saw

There’s a trick that might work here that uses an ADO Stream object as an intermediate buffer. If you can get your text into the adoStream, then you can use a Stream method to read it out in ‘C/AL sized’ bites. It goes something like this:VAR adoStream : Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Stream; BEGIN CREATE(adoStream); adoStream.Open; adoStream.WriteText(FedExAPI.FedExAPITransaction(...)); adoStream.Position := 0; WHILE adoStream.Position < adoStream.Size DO BEGIN myText := adoStream.ReadText(250); MESSAGE(myText); END; END;

As a general workaround, you can always create a “wrapper-object” in VB or C++ around the COM object in question. This wrapper-object will expose all the functionality of the original object and add all the functionality you need in addition. In your case, you can simply create a VB DLL or OCX which includes the FedExAPI object. For each function or property the FedExAPI provides, create a function or property with the same name, which does nothing but call the original FedExAPI function. Then you add a new function GetNextStringPortion(), which does just what you need, i.e. return the string in pieces suitable for Navision. This trick also works with COM objects which have function parameters incompatible with Navision types. I had one of those once…

Thank you Fritz for your suggestion. I tried the ADO Stream method this morning, and i still get the exceed buffer size limit error. Looks like I will have to try Heinz’s suggestion…creating a VB DLL. But thanks Fritz and Heinz for your suggestions ! Ailee

Just ask if you need assistance… Actually, it’s far easier than it might sound [;)]