Announcement

Collapse
No announcement yet.

How to print userdata

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to print userdata

    Code:
    require( "luacurl" )
    function open()
    remote = curl.new();
    return remote;
    end
    c = open();
    function SetOptions(parametre1,parametre2)
    c:setopt(parametre1,parametre2)
    end
    
    function perform ()
    c:perform();
    end
    
    function close()
    c:close();
    end
    SetOptions( curl.OPT_URL,"http://www.alldebrid.com/service.php?pseudo=username&password=parola&link=http://extremitysoft.com&json=true")
    SetOptions( curl.OPT_USERAGENT,"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36")
    SetOptions( curl.OPT_REFERER,"http://www.google.com.tr")
    SetOptions( curl.OPT_HEADER, true )
    SetOptions( curl.OPT_TRANSFERTEXT, true)
    perform()
    close()
    Dialog.Message("",type(c));
    I use these codes to type (c) and did not get the value in turning time.This userdata.

  • #2
    Code:
    Dialog.Message("",tostring(type(c)));

    Comment


    • #3


      The return value of this. But I would like to take over the values​​.

      Comment


      • #4
        Code:
        [font=Courier New][size=2]require([color=#800080]"luacurl"[/color]);
        
        [color=#0000FF][b]local[/b][/color] [color=#0000FF][b]function[/b][/color] __CurlWrite ([color=#FF0000].[/color][color=#FF0000].[/color][color=#FF0000].[/color])
            [color=#0000FF][b]if[/b][/color] (arg[color=#FF0000][[/color][color=#FF6600]1[/color][color=#FF0000]][/color])[color=#FF0000]:[/color]write(arg[color=#FF0000][[/color][color=#FF6600]2[/color][color=#FF0000]][/color]) [color=#0000FF][b]then[/b][/color] [color=#0000FF][b]return[/b][/color] [url=http://umodel.narod.ru/webhelp/ams/Program_Reference/Actions/string/string.len_lua.htm][color=#000000]string[/color][color=#FF0000].[/color][color=#000000]len[/color][/url](arg[color=#FF0000][[/color][color=#FF6600]2[/color][color=#FF0000]][/color]); [color=#0000FF][b]end[/b][/color]
        [color=#0000FF][b]end[/b][/color]
        
        [color=#0000FF][b]local[/b][/color] sLogPath   [color=#FF0000]=[/color] [color=#800080]"C:\\log.txt"[/color];
        [color=#0000FF][b]local[/b][/color] sURL       [color=#FF0000]=[/color] [color=#800080]"http://www.alldebrid.com/service.php?pseudo=username&password=parola&link=http://extremitysoft.com&json=true"[/color];
        [color=#0000FF][b]local[/b][/color] sUserAgent [color=#FF0000]=[/color] [color=#800080]"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36"[/color];
        [color=#0000FF][b]local[/b][/color] sReferer   [color=#FF0000]=[/color] [color=#800080]"http://www.google.com.tr"[/color];
        
        [color=#0000FF][b]local[/b][/color] hCurl [color=#FF0000]=[/color] [url=http://umodel.narod.ru/webhelp/ams/Program_Reference/Actions/curl/curl.new_lua.htm][color=#000000]curl[/color][color=#FF0000].[/color][color=#000000]new[/color][/url]();
        [color=#0000FF][b]if[/b][/color] hCurl [color=#0000FF][b]then[/b][/color]
            [color=#0000FF][b]local[/b][/color] hLogFile [color=#FF0000]=[/color] [url=http://umodel.narod.ru/webhelp/ams/Program_Reference/Actions/io/io.open_lua.htm][color=#000000]io[/color][color=#FF0000].[/color][color=#000000]open[/color][/url](sLogPath[color=#FF0000],[/color] [color=#800080]"wb"[/color]);
            [color=#0000FF][b]if[/b][/color] hLogFile [color=#0000FF][b]then[/b][/color]
                hCurl[color=#FF0000]:[/color]setopt(curl[color=#FF0000].[/color]OPT_WRITEFUNCTION[color=#FF0000],[/color] __CurlWrite);
                hCurl[color=#FF0000]:[/color]setopt(curl[color=#FF0000].[/color]OPT_WRITEDATA[color=#FF0000],[/color] hLogFile);
                hCurl[color=#FF0000]:[/color]setopt(curl[color=#FF0000].[/color]OPT_NOPROGRESS[color=#FF0000],[/color] [color=#0000FF][b]true[/b][/color]);
                hCurl[color=#FF0000]:[/color]setopt(curl[color=#FF0000].[/color]OPT_BUFFERSIZE[color=#FF0000],[/color] [color=#FF6600]5000[/color]);
                hCurl[color=#FF0000]:[/color]setopt(curl[color=#FF0000].[/color]OPT_URL[color=#FF0000],[/color] sURL);
                hCurl[color=#FF0000]:[/color]setopt(curl[color=#FF0000].[/color]OPT_CONNECTTIMEOUT[color=#FF0000],[/color] [color=#FF6600]15[/color]);
                [color=#0000FF][b]local[/b][/color] bOk[color=#FF0000],[/color] sErrStr[color=#FF0000],[/color] nRetCode [color=#FF0000]=[/color] hCurl[color=#FF0000]:[/color]perform();
                [color=#0000FF][b]if[/b][/color] bOk [color=#0000FF][b]then[/b][/color]
                    hLogFile[color=#FF0000]:[/color]write([color=#800080]"\r\nResource successfully saved as "[/color][color=#FF0000],[/color] sLogPath[color=#FF0000],[/color] [color=#800080]"\r\n"[/color]);
                [color=#0000FF][b]else[/b][/color]
                    hLogFile[color=#FF0000]:[/color]write([color=#800080]"Error: "[/color][color=#FF0000],[/color] sErrStr[color=#FF0000],[/color] [color=#800080]" ("[/color][color=#FF0000],[/color] nRetCode[color=#FF0000],[/color] [color=#800080]")\r\n"[/color]);
                [color=#0000FF][b]end[/b][/color]
            [color=#0000FF][b]end[/b][/color]
            hLogFile[color=#FF0000]:[/color]close();
        [color=#0000FF][b]end[/b][/color][/size][/font]

        Comment


        • #5
          You do not want to save the file with the value of the variable hLogFile. I do not want to print a file or. Can you help.

          Comment


          • #6
            Code:
            [font=Courier New][size=2][color=#0000FF][b]local[/b][/color] sLog [color=#FF0000]=[/color] TextFile[color=#FF0000].[/color]ReadToString(sLogPath);
            [color=#008000][i]--File.Delete(sLogPath, false, false, false, nil);[/i][/color]
            Dialog[color=#FF0000].[/color]Message([color=#800080]""[/color][color=#FF0000],[/color] sLog);[/size][/font]

            Comment


            • #7
              Thank you. hCurl: setopt (curl.OPT_WRITEDATA, this is apparently only able to write to the file. So hLogFile: lines () Do you have a chance to pull data from the form.

              Comment


              • #8
                curl.OPT_WRITEDATA also allows you to write to the buffer. But I have not dealt with this.

                Comment

                Working...
                X