GetChar ( )

Function stats

Average user rating
2.1429
52
113
9999
Support
FileMaker 7.0 +
Date posted
05 December 2008
Version
1
Recursive function
No

Author Info
 uLearnIT

7 functions

Average Rating 2.7

author_avatar



 

Function overview

Prototype

GetChar  ( text;   number )


Parameters

text  


number  


Description

Tags:  Text Parsing  

Returns the specified character (by number) from a string.
When using the Middle function to parse one character only, the character count is redundant.

Examples

Sample input

GetChar ( "David"; 3 )


Sample output

v

 

Function code

/*
GetChar ( text; number )
Purpose: Returns the specified character (by number) from a string.
Author: David Head, uLearnIT
*/

Middle ( text ; number ; 1 )

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/113

    Prototype: GetChar( text; number )
    Function Author: uLearnIT (http://www.fmfunctions.com/mid/52)
    Last updated: 05 December 2008
    Version: 1

*/
// ===================================

 

Comments

Fitch
19 December 2008



What is thte advantage in using this CF rather than simply using the Middle function?
  General comment
uLearnIT
19 December 2008



Thank you for asking the question. Although not at all difficult, this function fits neatly with the existing GetValue function provided in FileMaker Pro. When using Middle, I find that much of the time I am looking for one character only so the numberofChar argument is always 1. This function simplifies the expression you use when extracting a single word. I feel that this is a very strong feature of custom functions - simplifying expression and meaning.
  General comment
Genx
01 December 2010



While not particularly ingenious, I don't think the function needs to be rated down to two stars. To be honest it should probably be included in the FM core library along with GetValue - just because you can do something another way, doesn't mean there shouldn't be a simpler more direct way to get what you're after. When coding in PHP, Ruby or .Net for example you have a whole arsenal of string parsing functions that allow you to produce the cleanest code possible in the most efficient way possible - don't know why you wouldn't have the same for FM.

GetWord( string ; position ) or GetChar( string ; position ) is significantly easier to interpret when reviewing code (just from a human readability standpoint) than MiddleWords( string ; startposition ; 1 ) or Middle( string ; startposition ; 1 ).

Arguably, having it posted on this site provides a consistent reference point for one form of the function which could be referred back to between projects.

Just my 2c.
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)