Posts: 451
Threads: 16
Joined: Feb 2003
I need to know what string needs to be dereferenced, it seems some strings return a pointer the string data and some a pointer to a pointer to the string data.
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Posts: 922
Threads: 15
Joined: Jun 2003
I dunno what you want to do, @ returns the ptr to the string descriptor, strptr() and sadd() return the pointer to string data, "dim mystr as string ptr: mystr = @somestr: *mystr = "abc"" will set somestr's descriptor, and so on..
Posts: 1,272
Threads: 36
Joined: Feb 2003
Sorry if this is a little OT (this could be what he means by dereference), but does myString[index] do anything?
I guess we've got ASC(MID$()) for that, but ASC(MID$()) is slow...
PowerBASIC has ASC(myString, index)
Then again we can always PEEK(strptr(myString) + index - 1), which is better anyway because it seems to involve zero function calls - thanks for making strptr inline!
Posts: 922
Threads: 15
Joined: Jun 2003
mystring[] will access the descriptor only.
With pointer typecasting we could do something like <byte ptr>mystring[idx], but they are on the TODO list, will need much more hacking..
I didn't know PB's ASC could be used like that, could be simple to add.
Posts: 451
Threads: 16
Joined: Feb 2003
Yeah, I was looking for a way to get the string data to copy it to another location (not a string) but I didn't know about StrPtr().
StrPtr() works, but I would prefer a non-function method. Not that it's called often.
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Posts: 1,407
Threads: 117
Joined: Dec 2002
Quote:I didn't know PB's ASC could be used like that, could be simple to add.
It would be a very useful feature. I have seen it as GETMID(a$,index) and it's opposite PUTMID(a$,index,value) in a basic for a microcontroller.
Antoni
Posts: 1,439
Threads: 15
Joined: Apr 2003
Quote:StrPtr() works, but I would prefer a non-function method. Not that it's called often.
I think it's inlined...
Posts: 922
Threads: 15
Joined: Jun 2003
Yeah, varptr, strptr, procptr, sadd and @ are all inline.
Posts: 451
Threads: 16
Joined: Feb 2003
Ahh, then no worries. v1c, there was something I needed to ask you about fb, but for the life of me I can't remember. Do you happen to know what it is?
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'