Jump to content

Photo

string.zh


  • Please log in to reply
10 replies to this topic

#1 Joe123

Joe123

    Retired

  • Members

Posted 25 April 2010 - 12:34 PM

Is now included in ZC's downloads as of build 1232.
Here is a small set of example usages for most of the functions.

Example Code

EDIT:
The attachment now contains string.zh updated for builds 1280 and above ~Joe123

Attached Files



#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 25 April 2010 - 09:17 PM

Why is NULL -1? If you return NULL then you are returning true in that case.

#3 Joe123

Joe123

    Retired

  • Members

Posted 26 April 2010 - 06:49 AM

What do you mean you're returning 'true'?
It's an integer not a boolean...

Anyway 0 is a valid pointer so you can't have it as the null pointer.

#4 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 26 April 2010 - 06:51 PM

I know the difference between an integer and a bool. :razz:


You're missing the point; NULL MEANS ZERO. That's it's definition. It's like saying #define FALSE TRUE

It should be INVALID_POINTER, or ITER_OUT_OF_BOUNDS, ..or something.

#5 Joe123

Joe123

    Retired

  • Members

Posted 27 April 2010 - 01:56 AM

Suck it up and put if(ptr == NULL) rather than if(!ptr)

#6 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 27 April 2010 - 06:18 AM

No need to get so offensive, It doesn't bother me any. ..I mean If I really really don't like it I'll just change it to 0, which I haven't done btw.
I was merely pointing out that that constant might be named goofy. Since it doesn't refer to an actual pointer or memory address you don't have to name it null ( Which is zero btw icon_razz.gif ).

#7 Joe123

Joe123

    Retired

  • Members

Posted 27 April 2010 - 07:22 AM

Oh I didn't mean to be offensive =S
You can't change it to zero, the point of it is that it doesn't point to anything and 0 does point to something. I know that NULL is 0 in C.

#8 lucas92

lucas92

    Defender

  • Members

Posted 22 July 2010 - 03:22 PM

I've tried to import string.zh and it says that PointerOffset is not declared at line 307, which I assume is built-in in the scripting language... :S

I'm on build 1281.

Edited by lucas92, 22 July 2010 - 03:22 PM.


#9 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 22 July 2010 - 06:18 PM

PointerOffset was removed because ZScript now has proper arrays instead of a big static cache of values. Just delete the references to it.

#10 Joe123

Joe123

    Retired

  • Members

Posted 23 July 2010 - 03:43 AM

Oh yeah sorry, I updated the way arrays work but I haven't updated string.zh yet, I need to change it to take a position in the string as an argument rather than assuming the user supplies pointer to a position in the string like C 'cause pointers are different now, it won't take long but I'm lazy.
I'll try get it out for the next build, I've got a couple of other tasty ZScript functions to add too (finally used your 'SetArray' function Gleeok ^^).

#11 Joe123

Joe123

    Retired

  • Members

Posted 25 July 2010 - 02:23 PM

OK, seeing as a few people have asked I've updated string.zh, have a look at the first post.

If anyone could have a go running it through the tests and seeing if anything un-toward happened I'd really appreciate it...


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users