/
ColumnSlice.fmfn
65 lines (61 loc) · 1.37 KB
/
ColumnSlice.fmfn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* =====================================
* ColumnSlice ( data ; column )
*
* PURPOSE:
* Does stuff with argument1 and argument2.
*
* RETURNS:
* A return-delimited list of values from a specific column in data.
*
* PARAMETERS:
* data: A list of data delimited according to the default settings of the
* ExecuteSQL function.
* column: The number of the column to select.
*
* DEPENDENCIES: none
*
* HISTORY:
* CREATED on 2013-01-26 by Jeremy Bante <http://scr.im/jbante>.
* =====================================
*/
Case (
/* Step 0, set-up */
not $~cs.step ;
Let ( [
$~cs.rowCount = ValueCount ( data ) ;
$~cs.step = If ( $~cs.rowCount > 0 ; 1 ; /* Else */ 2 )
] ;
ColumnSlice ( data ; column )
) ;
/* Step 1, gather values from specified column */
$~cs.step = 1 ;
Let ( [
$~cs.i = $~cs.i + 1 ;
~row = Substitute ( GetValue ( data ; $~cs.i ) ; "," ; ¶ ) ;
~column = GetValue ( ~row ; column ) ;
$~cs.result =
$~cs.result
& If ( $~cs.i > 1 ; ¶ )
& ~column ;
$~cs.step =
If ( $~cs.i ≥ $~cs.rowCount ;
$~cs.step + 1 ;
/* Else */ $~cs.step
)
] ;
ColumnSlice ( data ; column )
) ;
/* Step 2, clean-up and return result */
$~cs.step = 2 ;
Let ( [
~result = $~cs.result ;
// purge variables
$~cs.i = "" ;
$~cs.result = "" ;
$~cs.rowCount = "" ;
$~cs.step = ""
] ;
~result
)
)