Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
v1ct0r: String dereferencing, when?
#1
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.'
Reply
#2
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..
Reply
#3
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!
Reply
#4
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.
Reply
#5
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.'
Reply
#6
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
Reply
#7
Quote:StrPtr() works, but I would prefer a non-function method. Not that it's called often.

I think it's inlined...
Reply
#8
Yeah, varptr, strptr, procptr, sadd and @ are all inline.
Reply
#9
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.'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)