Strings: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 13: Line 13:
Example:
Example:
     "one two three" findi "TWO" , result is 4
     "one two three" findi "TWO" , result is 4
yes. well, big deal. what's NOT documented is when it can't be found for shite's sake
answer = nil
thus a fairly straightforward
if ( (somestring findi "nothere") < 0) will fail, it's always there because it's NIL (jesus)
(>=0 will work)
note to self, some would-be language makers should read the perl cookbook which states fairly early on
" we take some things to be self evident"




Line 40: Line 55:
==String strCmp String==
==String strCmp String==


returns stanard c strcmp()
returns standard c strcmp()
 
case insensitive equivalent ==
 
(tolower String) strCmp (tolower String)
 
i've put brackets round this because in this language, the use of them is un-intuitive and NEVER self evident. Sometimes their use is contradictory
 
if you need bullet proof, (everything) sigh





Revision as of 14:07, 16 March 2010

General

File Commands

O2 Comref


"string" find/findi "what"

returns offset to start of string

Example:

   "one two three" findi "TWO" , result is 4

yes. well, big deal. what's NOT documented is when it can't be found for shite's sake

answer = nil

thus a fairly straightforward

if ( (somestring findi "nothere") < 0) will fail, it's always there because it's NIL (jesus)

(>=0 will work)

note to self, some would-be language makers should read the perl cookbook which states fairly early on

" we take some things to be self evident"


string @ idx

Example:

   "Hello" @ 2 , result is "l"

string @ [from,to]

returns a substr

Example:

   "Hello world" @ [2,7] , result is llo w


str AnyThing

returns "whatever anything is"

example:

str _thing;

String strCmp String

returns standard c strcmp()

case insensitive equivalent ==

(tolower String) strCmp (tolower String)

i've put brackets round this because in this language, the use of them is un-intuitive and NEVER self evident. Sometimes their use is contradictory

if you need bullet proof, (everything) sigh


note, case sensitive unfortunately

tolower

toupper

tolower string;

std c functions

example

_val= "this" strcmp tolower"tHiS";