How to pass variable by reference in javascript? Read data from ActiveX function which returns more than one value

前端 未结 4 1247
野性不改
野性不改 2020-12-19 09:33

I have a ActiveX object which I want to use in the browser (javascript).
There is a function I want to call. Its prototype is:

function TOPOSFiscalPrinte         


        
4条回答
  •  无人及你
    2020-12-19 10:25

    Make a global variable or object. Or if you're worried about other funcs accessing and changing the variables then make a singleton. The other option is to return an object. Such as like this

    function TOPOSFiscalPrinter.DirectIO(Command: Integer; var pData: Integer;
      var pString: WideString): Integer;
    
    function TOPOSFiscalPrinter.DirectIO(Command, pData, pString){
        ....
    
        var pObj = {
            d: 0,
            s: '',
            code: ''
        }
        pObj.d = pDataAltertedValue;
        pObj.s = pStringAltertedValue;
        pObj.code = code;
        return pObj;
    }
    
    function test() 
    {
        var d=1, s="DIRECIO:";
        var r = opos.DirectIO(1024, d, s);
        code = r.code;
        d = r.d;
        s = r.s;
    
    
    
        alert(d); alert(s);
    }
    

提交回复
热议问题