Question About Console Warnings: Attempt to call a ______ value

I am working on a Derma window that browses directories and can open a file and I have a question about some text that shows up in the console. Here’s my code:
[lua]
function FileDialog(up, open, cancel)

DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetSize( 600, 800 )
DermaPanel:SetTitle( "Open File" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( false )
DermaPanel:MakePopup()

path = "C:\\"

local DermaTextPath = vgui.Create( "DTextEntry", DermaPanel)
DermaTextPath:SetValue( path ) -- Change to default directory
DermaTextPath:SetPos( 25, 25 )
DermaTextPath:SetWide( 510 )
DermaTextPath:SetTall( 20 )
DermaTextPath:SetEnterAllowed( true )
function DermaTextPath:OnEnter()
	path = DermaTextPath:GetValue()
end

local DermaListView = vgui.Create( "DListView" )
DermaListView:SetParent( DermaPanel )
DermaListView:SetPos( 25, 100 )
DermaListView:SetSize( 550, 625 )
DermaListView:SetMultiSelect( false )
DermaListView:AddColumn( "Name" )

Msg(file.Find(path)) -- Delete this after you see it printed

for k,v in pairs(file.Find(path)) do -- Make sure this works
	DermaListView:AddLine(v) -- Make sure v works
end

local DermaButtonOpen = vgui.Create( "DButton")
DermaButtonOpen:SetParent( DermaPanel )
DermaButtonOpen:SetDisabled( false )
DermaButtonOpen:SetText( "Open" )
DermaButtonOpen:SetPos( 475, 750 )
DermaButtonOpen:SetSize( 100, 25 )
DermaButtonOpen.DoClick = open

local DermaButtonCancel = vgui.Create( "DButton", DermaPanel)
DermaButtonCancel:SetText( "Cancel" )
DermaButtonCancel:SetPos( 25, 750 )
DermaButtonCancel:SetSize( 100, 25 )
DermaButtonCancel.DoClick = cancel()

local DermaButtonUp = vgui.Create( "DSysButton", DermaPanel )
DermaButtonUp:SetPos( 535, 25 )
DermaButtonUp:SetSize( 20, 20 )
DermaButtonUp:SetType( "up" )
DermaButtonUp.DoClick = up

end

concommand.Add( “FileDialog”, FileDialog )

function up(path)
path = path … “…/” – Need to test if this will update in text box instantly after you replace the default text if it works
Msg( path )
end

function open(path)
print(file.Read(path))
end

function cancel()
DermaPanel:Remove()
end
[/lua]
When I click the cancel button on my window I always get a message in orange text that says: ‘Attempt to call a table value’. Why would it say that? As far as I can see the cancel function has nothing to do with tables. My guess is that the orange text is some kind of warning. Oh yeah, and the cancel button doesn’t work either.

I also get similar messages for my up button and my open button.
up: attempt to call a userdata value
open: attempt to call a string value (This one sort of makes sense since I am using a string in this function).

By the way, I haven’t gotten the file browsing part working but if you have any suggestions feel free to throw 'em here.

snip, bad reading.
Also you need the rawio module to browse outside your gmod folder.

Yeah, I read somewhere that you can’t leave the gmod folders but I haven’t really tried working around that yet. Thanks.

Do you really expect help without posting the exact error?

Well, to start off, all of your functions are globals, so they could easily be overridden by other badly written scripts. The problem I’m seeing here is that you set the cancel’s DoClick function to the return value of cancel().

[lua]DermaButtonCancel.DoClick = cancel()[/lua]

What that does, is call cancel(), gets what it returns (nil) and sets it as the DoClick function.

I don’t believe that to be possible. At least haven’t heard of anything yet, without rawio module.

I did. The ONLY thing that is printed when I press the cancel button are THESE words:

Overv is correct. You would need to remove the () from the cancel() to make it work properly.

Oh, I think this’s because I put the parentheses after cancel. I don’t have them on the other buttons but they still do that so maybe I’m wrong. Do you know what I should do instead?

I did this because that’s what I was told to do here:
http://mawrp.zoka.cc/forums/index.php/topic,54.msg272.html#new
At the top post (#30) you can see MawringFox gave me a small sample of how the structure of the code should work. Is what he said wrong?

You remove them, just like with the other buttons. Because then you actually set the button’s DoClick to your function and not just what it returns.

Please, take a closer look at my code up there. The cancel button was the only one with the parentheses and yet the other buttons still made an error. Is this thing even a real error? It doesn’t specify any lua file or line number and it’s in orange text.

Then I’m fairly sure it’s because you made all your functions globals. When you make open, up and cancel locals, remember to put them above your panel creation function.

Okay well I tried making them local but it still doesn’t work. Here’s my newer code:
[lua]
local function up(path)
path = path … “…/” – Need to test if this will update in text box instantly after you replace the default text if it works
Msg( path )
end

local function open(path)
print(file.Read(path))
end

local function cancel()
DermaPanel:Remove()
end

function FileDialog(up, open, cancel)

DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetSize( 600, 800 )
DermaPanel:SetTitle( "Open File" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( false )
DermaPanel:MakePopup()

path = "C:\\Program Files\\Steam\\steamapps\\whitellama11\\garrysmod\\garrysmod\\data" -- Default path

local DermaTextPath = vgui.Create( "DTextEntry", DermaPanel)
DermaTextPath:SetValue( path )
DermaTextPath:SetPos( 25, 25 )
DermaTextPath:SetWide( 510 )
DermaTextPath:SetTall( 20 )
DermaTextPath:SetEnterAllowed( true )
function DermaTextPath:OnEnter()
	path = DermaTextPath:GetValue() -- My path is always what this is after enter
end

local DermaListView = vgui.Create( "DListView", DermaPanel )
DermaListView:SetPos( 25, 100 )
DermaListView:SetSize( 550, 625 )
DermaListView:SetMultiSelect( false )
DermaListView:AddColumn( "Name" )

Msg(file.Find(path)) -- Delete this after you see it printed

for k,v in pairs(file.Find(path)) do -- Make sure this works
	DermaListView:AddLine(v) -- Make sure v works
end

local DermaButtonOpen = vgui.Create( "DButton", DermaPanel)
DermaButtonOpen:SetDisabled( false )
DermaButtonOpen:SetText( "Open" )
DermaButtonOpen:SetPos( 475, 750 )
DermaButtonOpen:SetSize( 100, 25 )
DermaButtonOpen.DoClick = open

local DermaButtonCancel = vgui.Create( "DButton", DermaPanel)
DermaButtonCancel:SetText( "Cancel" )
DermaButtonCancel:SetPos( 25, 750 )
DermaButtonCancel:SetSize( 100, 25 )
DermaButtonCancel.DoClick = cancel

local DermaButtonUp = vgui.Create( "DSysButton", DermaPanel )
DermaButtonUp:SetPos( 535, 25 )
DermaButtonUp:SetSize( 20, 20 )
DermaButtonUp:SetType( "up" )
DermaButtonUp.DoClick = up

end

concommand.Add( “FileDialog”, FileDialog )

[/lua]

-this solution is too retarded according to whitellama’s standards-

Then you’re doing it wrong. There should be a line number.

Wow retard. Run the script yourself and you’ll see no line number. Do you need me to take a screenshot for you?

Ahahaha. Haha. Yes. Made my day.

[img_thumb]http://www.facepunch.com/fp/rating/emoticon_tongue.png[/img_thumb]

Do you suffer from a mental illness?

This keeps getting better and better.

Maybe we should stop before this evolves into a flame war. I can see you quivering in fear through your avatar.