How can use both jscript and VBScript together in one AFL

When i use both jscript and VBScript in one afl
Got compilation error
Please help me
Both code are very important


  function _Parse( json_string )
	return JSON.parse( json_string );
function ParseJSON( json_string )
   script = GetScriptObject();
   return script._Parse( json_string );
JSONObj = ParseJSON( "{ \"firstName\": \"John1\",  \"lastName\": \"Smith1\" }" );

Title = "First name is " +  JSONObj.firstName + ", Last name is " + JSONObj.lastName;

Public Sub ServiceCall(Method, Url, StrJSON)

Dim WebRequest
set WebRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
on error resume next
WebRequest.SetTimeouts 300, 300, 300, 300 Method, Url, False
WebRequest.setRequestHeader "Content-Type", "application/json"
WebRequest.setRequestHeader "accept", "application/json"

If Method = "POST" OR Method = "PUT" Then
WebRequest.send strJSON
End if

responseText  = WebRequest.responseText
responseStatus = WebRequest.status

set WebRequest = nothing
End Sub

function SendOrder(Method, Url, StrJSON)
vbScriptObject = GetScriptObject();
return vbScriptObject.ServiceCall(Method, Url, StrJSON);

You can either have Javascript or VBScript in single formula. Can't have both.
Using them both at the same time is pointless because they both expose the same functionality.

And you definitely DO NOT need VBScript to make web requests. Web requests can be sent directly from AFL

InternetSetHeader function is also added in newest AmiBroker (6.39 or higher)

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.