handle adresses
Miscellaneous Forums/General Discussion/handle adresses
Images, B+ gadgets, banks, you name it .. all have those adresses like 21837729 orso .. is this *always* the case, no matter the system it runs on?
Can I assume that there's no adress going to be used below a certain number? like number 10000 orso? Or even a million ?
They are memory dresses, so they *could* be any value, but window usully takes up few million bytes, so less than a million is almost certainly never going to be the case.
[edit]
Saying that, if something in lower memory gets shifted out, and a blitz entity gets given that address, then you could have something under a million
hm... the plan I had was to have a function-arguement acting for handles as well as normal numbers under 10 orso..
Then inside the function I'd have:
Select arg
Case 0
arg=not_a_handle
Case 1
arg=not_a_handle
Case 2
arg=not_a_handle
Case 3
arg=not_a_handle
[..]
Case 10
arg=not_a_handle
[..]
Default ; more than 10??
arg=a_handle
End Select
But I guess for this low amount of numbers, there's not going to be much of an issue ..
I personally wouldn't bank on a handle being in any range or not. I even debated using a handle variable which sometimes had a value of -1 so it would do something different but decided against it. Boringly you could "wrap" the handle in a type so it had a IsHandle% field and another one for the actual handle.
CS_TBL: Bit confused as why you'd use a Select Case instead of If arg <= 10 atg=not_a_handle else arg=a_handle
So, you basically want a function that can take a handle OR an int as a parameter, yes? Why don't you just have a second parameter that signals the type of input? Like:
Const PARAM_INT = 0
Const PARAM_HANDLE = 1
Function my_func(arg%, arg_type%=PARAM_HANDLE) ; Default to handle input.
If arg_type = PARAM_HANDLE
; Do handle stuff.
Else
; Do integer stuff.
EndIf
End Function
Or you could just have a handle param AND an integer param:
Function my_func(handle%, integer%)
If handle
; Do stuff with 'handle' param.
Else
; Do stuff with 'integer' param.
EndIf
End Function
Not very elegant, I know, but it is a way. :)
grey: because I want to do things based on that number.. so in this case it's 10 different functions or a handle, there's supposed to be more code in those case-scopes you know :P
big1op:
I wish to get rid of 'more than one argument', as well as consts/globals :P .. heck I want 'nothing' extra.. just the sober self-contained function.
I can see certain nice things you could do with 1 arguement acting as 2 things, what about this:
Function DrawSquare(x,y,w,h,style)
where style is:
0 : red
1 : green
2 : green
3 : yellow
4 : lightblue
5 : purple
6 : white
7 : black
8 : darkgrey
9 : lightgrey
10: image
These colors are inside the function ofcourse, the user can now decide with one single argument what the square could look like, they user gives either a colornumber (0..9) or an imagehandle (some 21486731 number). And if handles are *always* in a certain range, or at least bigger than, say, 100.. then this is perfectly possible.
What's wrong with having two separate functions for that kind of thing?
Function DrawColorSquare(x,y,w,h,color)
Function DrawImageSquare(x,y,w,h,image)
having 2 functions where 1 will do .. less=more (imho) .. it *can* work when I've the assurance that handles stay at least above 100 orso ..
Besides I'm not planning such a drawfunction, it was just a hypothetical example..