Post Reply 
direct string access is curious
10-19-2015, 10:11 AM
Post: #8
RE: direct string access is curious
Perhaps useful(?):

If a variable contains a string, then (example):

var:="abcd";
n:=length(var);


var(2); // => ascii value of 2nd char: 98
var(2,2); // => sub string starting at the 2nd char for 2 chars length: "bc"
var(2,n); // => sub string starting at the 2nd char for length of string: "bcd"

If a string is an element within a list:

L0:={var}; // L0 is set to the contents of var

then:

L0(1); // => "abc"
L0(1,2); // => ascii value of the 2nd character of the 1st element: 98
L0(1,2,2); // => sub string beginning at the 2nd char for 2 chars: "bc"
L0(1,2,n); // => sub string beginning at the 2nd char for length of string: "bcd"

Nice shorthand for the SUB() function!

-Dale-
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
direct string access is curious - ji3m - 10-17-2015, 12:17 PM
RE: direct string access is curious - Han - 10-17-2015, 01:28 PM
RE: direct string access is curious - ji3m - 10-17-2015, 02:45 PM
RE: direct string access is curious - DrD - 10-17-2015, 03:51 PM
RE: direct string access is curious - ji3m - 10-18-2015, 10:24 PM
RE: direct string access is curious - DrD - 10-19-2015 10:11 AM



User(s) browsing this thread: 1 Guest(s)