|
|
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
OP
Senior Member
|
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: jcl]
#149232
08/21/07 11:09
08/21/07 11:09
|
Joined: Mar 2005
Posts: 309 Germany, Bavaria
Sinthoras
OP
Senior Member
|
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
Member
|
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
Expert
|
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
OP
Senior Member
|
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.
|
|
|
|