Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP Option Explicit - Paypal Express Checkout trouble

I am facing a big trouble when integrating PayPal Express Checkout in classic ASP.

The code provided by PayPal at the "PayPal Integration Wizard" works perfectly when run without Option Explicit.

When I put into my coding pages and call to the functions provided, I am facing big trouble: My existing pages all use Option Explicit.

This results in me having to manually declare all variables in the PayPal functions.

The sample PayPal functions consist of many array/list/object/index for setting up the name/value pairs necessary to call the PayPal site. It is totally not easy for me to change it over to all correct declaration, since I am not ASP expert and project deadline is tight.

Can anyone give me some advice?

like image 897
i need help Avatar asked Dec 08 '25 18:12

i need help


1 Answers

It seems to be possible to mix "Option Explicit"-code with non-"Option Explicit"-code via the Execute statement.

Here's a small test I just made with VBScript (which applies to classic ASP as well):

''#vb1.vbs (i.e. "your code")
Option Explicit

Dim fso, vb2, txt
Set fso = CreateObject("Scripting.FileSystemObject")
Set vb2 = fso.OpenTextFile("vb2.vbs", 1)
txt = vb2.ReadAll

MsgBox txt    ''# Message 1
Execute txt

MsgBox foo    ''# Message 2

and

''# vb2.vbs (i.e. "their code")
j = 100

Function foo
  k = 100
  foo = j + k
End Function

Results in:

Message 1: (equal to the contents of vb2.vbs)
Message 2: 200

I have no idea if this is the best way to do it, but currently I can think of no better way. Give it a try.

Beware of namespace clashes through global variables or function names in "their code".

like image 155
Tomalak Avatar answered Dec 10 '25 13:12

Tomalak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!