How do i convert handle value ?

atuldalvi

Member
I am storing handle value ( SESSION:FIRST-CHILD ) in a character variable which is 112324 and then again trying to convert this value to handle. but while displaying it is showing zero.

Is it possible to convert handle to character and vice versa ?
 
Why are you storing it in a character variable? Why not store it in a variable of type handle?
 
actually i am trying to store that handle value in a shared variable while session start and accessing that value in a next screen.
 
Or simply use the correct functions for conversion. You do not mention what you have tried. You can use the HANDLE function to convert the character representation back to a handle. Note that the handle must of course still be valid!

Code:
DEFINE TEMP-TABLE tt
   FIELD cc AS CHAR
   .
DEF VAR cch AS CHAR.
DEF VAR hh AS HANDLE.
CREATE tt. tt.cc = "hello".
cch = STRING( TEMP-TABLE tt:DEFAULT-BUFFER-HANDLE ).
hh = HANDLE( cch ).
MESSAGE hh::cc VIEW-AS ALERT-BOX.
 
can i user the statement 'DEFAULT-BUFFER-HANDLE' with variables ?

And which magical feature would you expect that to give you?

I used DEFAULT-BUFFER-HANDLE in my example to illustrate converting a handle to a character and back. If you already have a HANDLE you can simply STRING() this into a character and HANDLE() it back. But as I mentioned with my example, putting a handle in a string (or another handle for that matter) will not prevent the 'copy' of the handle from becoming invalid / reused.
 
I am simply assigning below statement:

define var vhsessionfstchild# as char

vhsessionfstchild# = string(SESSION:FIRST-CHILD:DEFAULT-BUFFER-HANDLE).

but i am getting error ' Default-buffer-handle is not a query-able attribute for window widget'.
 

Attachments

  • error.JPG
    error.JPG
    25 KB · Views: 40
did you check the help pages for DEFAULT-BUFFER-HANDLE and the help for the error message using the message# ??
 
not all widgets are the same, it's like with procedures... some are more persistent than the other ;)

it's like asking anyone you meet what was his t-shirt number in college, some might just have other 'properties' to compensate :)
 
That error suggests that your FIRST-CHILD is a Window, and you are assuming it is a Query.

You could loop thru all the kidlets and check the type until you found a query ... but this whole line of thinking sounds kind of hopeless, to be honest.
 
Back
Top