Posted: Sat Feb 27, 2021 4:08 pm Post subject: Loaded code fails when activated.
Hello.
I have a sample code below.
It does not enable the line of code loaded from the remote server.
But it activates the line of code I have written by hand.
When I copied and pasted the remote server code line, it turned out to be like this;
Code:
showMessage( ello CEF )
Is there any way to fix this?
Here is the code for you to try;
Code:
if formd1 then formd1.Destroy() end
formd1 = createForm()
formd1.Position=poDesktopCenter
local md1=createMemo(formd1)
md1.Width=formd1.Width md1.Height=formd1.Height - 35
md1.WordWrap=false md1.ScrollBars="ssAutoBoth"
local mdb1=createButton(formd1)
mdb1.Width=200 mdb1.Height=25 mdb1.Left=60 mdb1.Top=formd1.Height - 30
mdb1.caption="Execute Code"
function LoadCode1()
local http = getInternet()
local result = http.getURL("https://docs.google.com/document/d/1vL0INl0eD1MHcWHWeTlns04U8rAnotCtFEJKtgxW7q4/export?format=txt")--edit?usp=sharing")
if result then
md1.Lines.Text=result
end
end
LoadCode1()
mdb1.OnClick=function()
ss11=md1.Lines.Text
if ss11~="" then
aa11=load(ss11)
if aa11~=nil then
load(ss11)()
else
showMessage("Please write executable code")
end
else
showMessage("Please write a code in the box.")
end
end
This has been a bit complicated.
A different question; Is there any way to delete the first line of "result" or "memo"?
So; From the second line, printing "result" to "memo".
EDIT:
Yes I think I found the solution.
I saw the error was in the first line.
Now I'll feed the first line (---) to delete it.
Code:
if formd1 then formd1.Destroy() end
formd1 = createForm()
formd1.Position=poDesktopCenter
local md1=createMemo(formd1)
md1.Width=formd1.Width md1.Height=formd1.Height - 35
md1.WordWrap=false md1.ScrollBars="ssAutoBoth"
local mdb1=createButton(formd1)
mdb1.Width=200 mdb1.Height=25 mdb1.Left=60 mdb1.Top=formd1.Height - 30
mdb1.caption="Execute Code"
function LoadCode1()
local http = getInternet()
local SL = createStringlist()
local result = http.getURL("https://docs.google.com/document/d/1vL0INl0eD1MHcWHWeTlns04U8rAnotCtFEJKtgxW7q4/export?format=txt")--edit?usp=sharing")
SL.text=result
if SL then
for x=1, strings_getCount(SL)-1 do
--print(SL[x])
md1.Lines.Add(SL[x])
end
end
SL.destroy();
end
LoadCode1()
mdb1.OnClick=function()
ss11=md1.Lines.Text
if ss11~="" then
aa11=loadstring(ss11)
if aa11~=nil then
loadstring(ss11)()
else
showMessage("Please write executable code")
end
else
showMessage("Please write a code in the box.")
end
end
Thanks for your time @Corroder.
NOTE: I am reviewing posts from you and @mgr.inz.Player.
I will continue to give +1 for every code that works for me. (Y)
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum