Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 712 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
no possibility to save a handle in a string #149230
08/20/07 18:53
08/20/07 18:53
Joined: Mar 2005
Posts: 309
Germany, Bavaria
Sinthoras Offline OP
Senior Member
Sinthoras  Offline OP
Senior Member

Joined: Mar 2005
Posts: 309
Germany, Bavaria
Hiho,

there might be a problem with saving the handle number of a panel into a string:

Code:

panel* PanelPointer;
panel TestPanel { ... }
...
temp = handle(TestPanel);
str_for_num(str1, temp); //save the handle to the string
PanelPointer = ptr_for_handle(temp); //works
temp = str_to_num(str1); //get the handle out of the string

PanelPointer = ptr_for_handle(temp); //does not work (returns zero)
...



The Problem occurs both on predefined panels and on panels created by pan_create, but it does NOT occur on string pointers/handles.

[EDIT] V6.60, C-Script [/EDIT]

Last edited by Sinthoras; 08/20/07 18:56.
Re: no possibility to save a handle in a string [Re: Sinthoras] #149231
08/21/07 05:33
08/21/07 05:33
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Of course this won't work. A handle can be stored in a variable, but is no variable and can not be converted to a number string.

Re: no possibility to save a handle in a string [Re: jcl] #149232
08/21/07 11:09
08/21/07 11:09
Joined: Mar 2005
Posts: 309
Germany, Bavaria
Sinthoras Offline OP
Senior Member
Sinthoras  Offline OP
Senior Member

Joined: Mar 2005
Posts: 309
Germany, Bavaria
Well, acording to the manual, it IS a number..

Manual "handle":
Code:

A handle is similar to a pointer, but is just a number and therefore can be assigned to any variable or skill.



And if it was no number... why does the string conversion work for string pointers/handles then?

Last edited by Sinthoras; 08/21/07 11:10.
Re: no possibility to save a handle in a string [Re: Sinthoras] #149233
08/21/07 15:11
08/21/07 15:11
Joined: Nov 2006
Posts: 141
South Africa
quasarchangel Offline
Member
quasarchangel  Offline
Member

Joined: Nov 2006
Posts: 141
South Africa
Why do you want to save it to a string?


God DID give us a manual on how to change this world...
Re: no possibility to save a handle in a string [Re: quasarchangel] #149234
08/21/07 18:01
08/21/07 18:01
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Well, i guess the problem is the conversion to the string and back, where you might loose precision. Keep in mind, that a handle is not equivalent to a var. A handle is an int, that contains a bit mask for the handle type and a unique number.


Always learn from history, to be sure you make the same mistakes again...
Re: no possibility to save a handle in a string [Re: Uhrwerk] #149235
08/22/07 09:48
08/22/07 09:48
Joined: Mar 2005
Posts: 309
Germany, Bavaria
Sinthoras Offline OP
Senior Member
Sinthoras  Offline OP
Senior Member

Joined: Mar 2005
Posts: 309
Germany, Bavaria
@quasarchangel

I want to save it to a string because my current database system works only with strings. This results from the pseudo database language I wrote for it. If theres no other way but keeping the handle a var, I have to change the language a bit.

@Uhrwerk

The precision could be the problem, yes. I will try to shift the commands to a dll, maybe it is possible to convert it by C++.


The strange thing about it is still that the conversion is possible for string handles.

[EDIT]
In a dll, it works with the itoa/atoi functions (also with "var"), but not with the str_for_num/str_to_num ones.
Might be the precision problem.

Code:

char c[20];
_itoa_s(handle(pointer), c, 20, 10);
str_cpy(str1, c);

and

return(ptr_for_handle(atoi(_CHR(str1))));



Problem solved.
[/EDIT]

Last edited by Sinthoras; 08/22/07 10:15.
Re: no possibility to save a handle in a string [Re: Sinthoras] #149236
08/22/07 10:44
08/22/07 10:44
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Saving handles as strings (not 3DGS strings), and reading them back in or resurrecting them again (via C / C++ file IO), in compliment with the 3DGS load / save instructions (in C-Script), seems to work as expected using a C++ interface and the 3DGS plugin SDK. This seemed to work well enough when I implemented load / save functionality for my entity lists eLL plugin (C file IO) and later for the newer version, el (C++ file stream classes IO) plugin.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1