[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  can anyone suggest how to implement http in lua code
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

can anyone suggest how to implement http in lua code

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Sweta   (4 posts)  [Biography] bio
Date Tue 06 Jul 2010 06:31 AM (UTC)
Message
while implementing http in lua code I am facing the problem.

for example : I tried the below one

local TEMPHTML = ""
local url ="http://www.dilbert.com/"
local objXMLHTTP = luacom.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP:Open ("GET",url , 0)
objXMLHTTP:Send()
TEMPHTML = objXMLHTTP.responseBody
objXMLHTTP = nil

it throws me a error like ,

attempt to index global 'luacom' (a nil value)
stack traceback:
try.lua:1: in main chunk
[C]: ?

Again i tried with other options like

extracting these files in lua directory..
-http.lua
-code.lua
-concat.lua
-url.lua
from luasocket-1.4.zip from :
http://www.tecgraf.puc-rio.br/luasocket/old/luasocket-1.4/

and put them in the lua directory...

then i tried the below one

local TEMPHTML = ""
local url ="http://www.dilbert.com/"
TEMPHTML = HTTP.get(url)

But it throws me a same error like ,

attempt to index global 'luacom' (a nil value)
stack traceback:
try.lua:1: in main chunk
[C]: ?

I have installed Lua for windows from http://www.lua.org/download.html

Please help me out to solve this,

Many Thanks in Advance
[Go to top] top

Posted by Erendir   Germany  (47 posts)  [Biography] bio
Date Reply #1 on Tue 06 Jul 2010 08:56 AM (UTC)
Message
to use a non-default lua-module(lib) like luasocket You have to require it first, like


require "socket"
require "http"

(or with dofile, as in examples from luasocket-1.4.zip)
[Go to top] top

Posted by Sweta   (4 posts)  [Biography] bio
Date Reply #2 on Tue 06 Jul 2010 10:30 AM (UTC)
Message
Thanks for your reply. I tried it but i am getting the below error message

no field package.preload['http'] and its automatically goes to http.lua file

function Private.receive_status(sock)
local line, err
line, err = %Private.try_receive(sock)
if not err then return %Private.get_statuscode(line), line
else return nil, nil, err end
end
and throwing error message like

lua: error loading module 'http' from file 'C:\Program Files\Lua\5.1\http.lua':
C:\Program Files\Lua\5.1\http.lua:87: unexpected symbol near '%'


Many Thanks in Advance
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 06 Jul 2010 11:47 AM (UTC)
Message
I am not familiar with the Lua syntax here:


line, err = %Private.try_receive(sock)


(In particular your use of "%").

Try reading this post:

Template:post=4935 Please see the forum thread: http://gammon.com.au/forum/?id=4935.


Also search for other uses of luasocket.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Sweta   (4 posts)  [Biography] bio
Date Reply #4 on Wed 07 Jul 2010 10:16 AM (UTC)
Message
I tried it with using Lua socket files but still. i am getting the sane eror message.

lua: ad.lua:3: attempt to index global 'luacom' (a nil value)
stack traceback:
ad.lua:3: in main chunk
[C]: ?

I have installed Lua For windows(SciTE) editor from http://code.google.com/p/luaforwindows/ and installed these two files additionally in this path C:\Program Files\Lua\5.1 ( Root directory of Lua)

1. luasocket-2.0-beta2.zip

2. luasocket-2.0-beta2

While installing Luafor windows Luacom is the Inbuilt property of it. But still am getting the nil value error.

Anyone please help me out in this regard.

Manythanks In Advance
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Wed 07 Jul 2010 10:01 PM (UTC)
Message
Template:post=8319 Please see the forum thread: http://gammon.com.au/forum/?id=8319.


Some "Lua for Windows" files use DLL names that do not agree with the ones MUSHclient uses. MUSHclient uses lua5.1.dll however some of the Lua binaries are linked to lua51.dll - this causes them to not load if you don't have lua51.dll there, or if you do they are running connected to a different DLL than the MUSHclient's Lua one.

If you follow the suggestions in the post above it should work.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Sweta   (4 posts)  [Biography] bio
Date Reply #6 on Mon 12 Jul 2010 10:20 AM (UTC)
Message
Thanks a ton. It may be working fine in MuSHclient Lua. But, I'm using SciTE editor. Can you please suggest me the steps for SciTE (Lua for windows). It would be helpful for me.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #7 on Mon 12 Jul 2010 03:24 PM (UTC)
Message
Is this a MUSHclient question or a SciTE question? Even if it's a SciTE question, why are you needing to execute code from within the text editor? (Are you using it as an IDE or something?)

What do you mean exactly by "using" the Lua file? What are you doing to run it?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Mon 12 Jul 2010 08:51 PM (UTC)
Message
You posted the question in the MUSHclient -> Lua section, so I assumed you were wanting to get some combination of MUSHclient and Lua working.

Although I used Scite a while back, I don't know enough to get Lua going in it. The Scite mailing list or FAQ may be more appropriate here.

I have been using Crimson Editor to run stand-alone Lua code where required. That was fairly easy to set up.

The link I gave before showed I had troubles getting the socket stuff to work, even in MUSHclient, if you don't get the directory structure right. Plus some DLLs have dependencies on others (the Windows Dependency Walker program can help with that) which means they don't load, although not through any direct fault of their own.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


21,151 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]