Re: BGT Handles

2018-04-13 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: BGT Handles

I'm not sure that it works with strings in bgt. I don't think it works with vectors, either. And not for primitives. So mostly for dictionaries, sounds, classes you create, that sort of thing.

URL: http://forum.audiogames.net/viewtopic.php?pid=359643#p359643




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: BGT Handles

2018-04-13 Thread AudioGames . net Forum — Developers room : Quacker via Audiogames-reflector


  


Re: BGT Handles

I've spent some time playing with this. While trying this out with strings, I get a compilation error saying that object handles are not supported for this type. Am I missing something?

URL: http://forum.audiogames.net/viewtopic.php?pid=359640#p359640




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: BGT Handles

2018-04-10 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: BGT Handles

I'm not quite sure why, but generally speaking, the only time you need the @ sighn on the right side of an = is when comparing (ex, if(@a==@b), but @a=b).

URL: http://forum.audiogames.net/viewtopic.php?pid=359146#p359146




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: BGT Handles

2018-04-10 Thread AudioGames . net Forum — Developers room : Quacker via Audiogames-reflector


  


Re: BGT Handles

Thanks so much! I've only very recently started on C++, so have only gotten as far as if statements and now starting onn loops. Haven't yet gotten to what would be comparable to this. Just to make sure I understand, here's the same example with my notes as to what I think I understand is happening. Please correct me if I'm wrong.// Creates a function that takes a handle to a string as a parameter.void print_string(string@ data){  // Prints the alert with the string for which the handle that was passed to it points to.  alert("handle printer", data);}void main(){  string data = "" quite a small string, but even i am already bulkier than my handle.";  // Not too sure here, but assuming it creates a handle that points to the previous data handle?  string@ data_handle = @data;  // Calls the print_string function and passes it a handle to the string data.  print_string(@data);  // Again, not sure, but assuming it calls the function again, passing it the handle that points to the handle of string data?  print_string(@data_handle);  // Again not sure, but guessing it creates a handle to string data?  print_string(data);}Thanks again for all the help!

URL: http://forum.audiogames.net/viewtopic.php?pid=359141#p359141




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: BGT Handles

2018-04-10 Thread AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector


  


Re: BGT Handles

This is basically references and passing by reference in C++.

URL: http://forum.audiogames.net/viewtopic.php?pid=359117#p359117




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: BGT Handles

2018-04-10 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: BGT Handles

Hi,i'm not surprised that you don't know about handles when coming from Python, since Python does all the handle stuff for you already. I'm a bit surprised that you don't know them from the C++ region though. Anyway, here's a bit of explanation.Any variable contains data, data which needs to be somewhere within the RAM, data which can grow in size. An integer variable with 32 bits is 4 bytes in size, which isn't that much, thats why you usually don't use integer handles that much. But there are variables which can actually grow rather large over time. Consider reading a file into a string which is multiple megabytes in size. The string will have exactly the same size, probably even more, due to null termination and what else. Whenever you call a function which uses this string and doesn't use handles, the compiler will create a copy of this string just to be used within this function. Copying is a rather time-consuming task, especially if the data which needs to be copied is huge.And now consider classes which contain multiple of those strings, each time you call a function with them as parameter they will get copied over, and those copies will be recycled as soon as the function terminates.To prevent the compiler from copying huge amounts of data where it isn't actually needed, some inteligent guys invented handles. A handle simply knows the location of specific data inside the RAM, and what type the data is which you can find there. Thats all. That results in a fixed handle size, no matter what data you put into the variable. The handle size differs from OS to OS, but its usually something between 4 and 16 bytes.OK, now you can, instead of copying data around in-memory, simply code a function which doesn't take the data itself, but a handle which shows the location of the data instead, because this handle is much smaller in size than the data itself. The function can then follow the handle towards the data and process it just like before.There are even more possible situations in which handles can become useful, like writing functions which return more than just one value, or just-in-place modification of data without the need of a return value, but those are more advanced and can be found on several handle (or pointer) tutorials on the net.Well, in BGT the thing works like this:void print_string(string@ data)
{
  // bgt does the dereferencing for us already, which is kinda confusing at times, but you'll probably get the hang of it
  alert("handle printer", data);
}
void main()
{
  string data = "" quite a small string, but even i am already bulkier than my handle.";
  string@ data_handle = @data;
  print_string(@data);
  // and because bgt always dereferences variables for us, we can access data_handle just like a usual string
  // so we need to reference it as well
  print_string(@data_handle);
  // it will print the exact same string twice, but in fact, its only stored in memory once
  // and thanks for the smart bgt interpreter, we can even do this:
  print_string(data);
  // since the interpreter knows that print_string() accepts a pointer, it will automatically and silently create a reference for us
}Hope that helped.Best Regards.Hijacker

URL: http://forum.audiogames.net/viewtopic.php?pid=359071#p359071




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector