Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Barnski's Lua and Strings

Author
Message
entomophobiac
21
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 23rd Jul 2009 12:25
I've been trying to figure out what the "Buffer" and "Buffer Size" variables are in the Lua plugin and simply can't get it to function properly.

The function's declaration looks like this:


...but the only documentation I've been able to find is connected to the DBP behavior and has nothing to do with the GDK.

Is anyone else using this plugin and, if so, how have you interpreted the use of this function?
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 23rd Jul 2009 13:07
I've been running into the same problem recently, and made a thread here, but I couldn't find a way to solve it. Was hoping that Barnski could see the thread and give us some advices.
entomophobiac
21
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 23rd Jul 2009 15:53
I haven't found a way either. I also find it really strange that it's not formatted the same as the other commands. But I guess it's part of C++'s occlusion of a standard string-class outside the STL.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 23rd Jul 2009 18:03
Im not sure what that function is for or what values you need to pass to it for it to work properly, but it is returning a character array pointer(char*) ... a null-terminated character "string" in other terms, if that helps with the use of it. Its taking 2 character array pointers as arguments aswell the memory size of the buffer... this could mean that it wants you to pass it your containing character array pointer(buffer), along with it's size(in bytes i guess, size_t is a typedef define for unsigned integer as is returned by sizeof) - I assume the "index_name" would be the place you are reading the string from ?

The other explanation could be that it is a legacy function left over from the port from DBPro to C++ .. only the author can answer that though I think.

If it ain't broke.... DONT FIX IT !!!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 23rd Jul 2009 20:02 Edited at: 23rd Jul 2009 20:03
I don't know anything about LUA but have you tried declaring a character array and passing that to the function? It seems to expect a buffer and the buffer size. The string would be returned in the Buffer array in this case and the return value of the function may be irrelevant.

entomophobiac
21
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 23rd Jul 2009 22:15
The char-array trick actually worked! Thanks, Mireben. I thought I'd tried everything, but it definitely turns out I was sorely mistaken.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 23rd Jul 2009 23:32
Not quite a trick - that's how it's usually intended to work.
entomophobiac
21
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 24th Jul 2009 11:58
It used to be the norm for C, absolutely. And in my opinion it's also the biggest drawback of C-derivative languages, object-oriented or not, at least when it comes to usability: they don't have a native string class.

A really weird decision, to be perfectly honest. But I guess it comes down to memory management on some level. Most things do in C++...
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 25th Jul 2009 16:48
I think C++ was designed to be more programmer-friendly than faster than C or anything.

I mean, look at virtual methods. What a nightmare.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 25th Jul 2009 20:19
Quote: "they don't have a native string class."


Consider the meaning of native class. Even back without classes, "plain ole C" didn't have native functions. What generally accompanied any of the compilers was a library of standard functions. However, they weren't part of the language. The same for C++ and C# classes. The functions and classes that you find are part of the standard distribution but not something built into the language. With C++ you typically have the Standard Template Library and with C# you have the framework.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 27th Jul 2009 14:10
Sorry for bumping this thread, but I have a question: Can we only use that plugin in debug mode? Cause it says C++ Library debug version 1.1.1. And I remember trying to compile my project using it, in release mode, and it wouldn't allow me.

Login to post a reply

Server time is: 2024-10-01 08:45:19
Your offset time is: 2024-10-01 08:45:19