Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function from another language
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Function from another language
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01337842
Message ID:
01337842
Vues:
76
I converted a funtion from VBScript to VFP

Only a line in the final of the fuction returns error message:

Stream.CharSet = CharSet

OLE IDispatch exception code 0 FROM ADODB

Below are the funcion I created and also the original funtion in the button
I'd be glad if someone could take a look


************ This is the function I created*************************************

Function QuotedPrintableDecode(SourceData, CharSet)
*Create CDO.Message object For the encoding.

Message = CreateObject("CDO.Message")

*Set the encoding
Message.BodyPart.ContentTransferEncoding = "quoted-printable"

*Get the data stream To write source string data
*public Stream &&As ADODB.Stream
Stream = Message.BodyPart.GetEncodedContentStream
If VarType(SourceData) = "C" && vbString
*Write the VBScript string To the stream.
Stream.WriteText = SourceData
Else
*'Set the type of the stream To adTypeBinary.
Stream.Type = 1
*Write the source binary data To the stream.
Stream.Write = SourceData
EndIf

*Store the data To the message BodyPart
Stream.Flush

*Get an encoded stream
Stream = Message.BodyPart.GetDecodedContentStream

*Set the type of the stream To adTypeBinary.
Stream.CharSet = CharSet &&& this line returns error

*You can use Read method To get a binary data.
QuotedPrintableDecode = Stream.ReadText
End Function



*****************************Original funcion*******************************************


'VBScript QuotedPrintableDecode decoding Function
'2005 Antonin Foller http://www.motobit.com
Function QuotedPrintableDecode(SourceData, CharSet)
'Create CDO.Message object For the encoding.
Dim Message: Set Message = CreateObject("CDO.Message")

'Set the encoding
Message.BodyPart.ContentTransferEncoding = "quoted-printable"

'Get the data stream To write source string data
Dim Stream 'As ADODB.Stream
Set Stream = Message.BodyPart.GetEncodedContentStream
If VarType(SourceData) = vbString Then
'Write the VBScript string To the stream.
Stream.WriteText SourceData
Else
'Set the type of the stream To adTypeBinary.
Stream.Type = 1
'Write the source binary data To the stream.
Stream.Write SourceData
End If

'Store the data To the message BodyPart
Stream.Flush

'Get an encoded stream
Set Stream = Message.BodyPart.GetDecodedContentStream

'Set the type of the stream To adTypeBinary.
Stream.CharSet = CharSet

'You can use Read method To get a binary data.
QuotedPrintableDecode = Stream.ReadText
End Function
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform