I have some questions about manipulating arrays in Xojo
Is it possible to determine the size of array created by split? Something like $# in perl
[code]tmp() as String
tmp = Split(“F1,F2,F3,F4,F5,F6,F7,F8,F9”, “,”)
In Perl it would be $#tmp which would equal 8[/code]
If I do tmp.remove 0 Does everything shift over, or does the array now start at 1
The LRM says there is a “pop” command: astring =tmp.pop which removes an item off the end of the array. What about manipulating the other end? Is there something akin to the perl shift/unshift? ( I realize that foo=tmp(0) and tmp.remove 0 could be equivalent to shift, depending on the answer to my previous question)
How do I specify a comma in a comma separated list of array elements?
tmp = Split(“F1,F2,F3,F4,F5,F6,F7,F8,comma?”, “,”)
The UBound function tells you the upper bound (size) of the array:
Dim size As Integer = UBound(tmp) // Returns 8 from your example
Everything shifts over.
I don’t know that you can.
If you haven’t already found them, all the array-related commands are in the Language Reference here: http://documentation.xojo.com/index.php/Category:Language_Arrays
You’d have to write your own code for that, probably around a regular expression. However, in this case, you could do this instead:
tmp() as String
tmp = Array( "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8,comma?" )
Paul: Thanks for the quick reply. I read the man page for remove and it did not specify how the resultant array would be structured. I should have seen ubound. I looked at several of the other array related commands. somehow I failed to read that one. Sorry
Kem: Thanks for the reply. I saw something similiar to what you suggest (SQLify) in section 12.5 on databases in Intro to Xojo. I wanted to see if there was something native like the way a " is escaped by using it twice
Quotes are the only things that can be escaped in strings. Strings are not evaluated as they can be in perl, so you also can’t, for example, include a variable within the string like, “my name is $name”.