StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Lua Scripts
 General Action Scripts
 Decode URL that is in Clipboard
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

spcom

11 Posts

Posted - 11/05/2016 :  08:58:28  Show Profile  Reply with Quote
Hi,

i am no programmer but i tried to decode an url that is in clipboard, but i get this error:

---------------------------
Lua Script Error!
---------------------------
[string "ActionScript"]:28: attempt to call global 'decodeURI' (a nil value)
---------------------------
OK
---------------------------

the code i tried looks like this:


str = acGetClipboardText()
acDelay(100)
decodeURI(str)
acDelay(100)
acSetClipboardText(str)


i also tried to replace decodeURI with other codes i found with internet search.
the error does not appear, but the url is not decoded.


str = acGetClipboardText()
acDelay(100)

local decodeURI
do
    local char, gsub, tonumber = string.char, string.gsub, tonumber
    local function _(hex) return char(tonumber(hex, 16)) end

    function decodeURI(s)
        s = gsub(s, '%%(%x%x)', _)
        return s
    end
end

print(decodeURI(str))

acDelay(100)
acSetClipboardText(str)


or


str = acGetClipboardText()
acDelay(100)

local hex={}
for i=0,255 do
    hex[string.format("%0x",i)]=string.char(i)
    hex[string.format("%0X",i)]=string.char(i)
end

local function decodeURI(s)
    return (s:gsub('%%(%x%x)',hex))
end

print(decodeURI(str))

acDelay(100)
acSetClipboardText(str)


any solutions for my problem?

Edited by - spcom on 11/05/2016 09:53:46
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000