Link | lp_array_join |
Author | Bil Corry |
Category | Array |
Version | 8.x |
License | Public Domain |
Posted | 02 Dec 2005 |
Updated | 02 Dec 2005 |
More by this author... |
Joins an array, similar to array->join, but with additional options.
var:'test' = (array: 'a','b','c','d','e'); lp_array_join: $test, ', ', -front='"', -back='"', -last=' and '; var:'in' = (lp_array_join: (: 'abc','def','ghi'), "','",-front="('", -back="')"); var:'sql' = "select * from table where mycol in " $in; '
'; $sql; Returns: "a, b, c, d and e" select * from table where mycol in ('abc','def','ghi')
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
[ define_tag:'lp_array_join', -description='Similar to array->join, but with more options.', -required='array',-copy, -optional='join', -optional='front', -optional='back', -optional='first', -optional='last'; if: #array->type != 'array'; #array = (array: #array); /if; if: !local_defined:'join'; local:'join' = ''; /if; if: !local_defined:'front'; local:'front' = ''; /if; if: !local_defined:'back'; local:'back' = ''; /if; if: !local_defined:'first'; local:'first' = #join; /if; if: !local_defined:'last'; local:'last' = #join; /if; if: #array->size == 0; return: null; /if; if: #array->size == 1; return: #front (#array->(get: 1)) #back; /if; if: #array->size == 2; if: #last->size; return: #front (#array->(join: #last)) #back; else: #first->size; return: #front (#array->(join: #first)) #back; else; return: #front (#array->(join: #join)) #back; /if; /if; local:'firstone' = (#array->(get: 1)); #array->(remove: 1); local:'lastone' = (#array->(get: #array->size)); #array->(remove: #array->size); return: #front #firstone #first (#array->(join: #join)) #last #lastone #back; /define_tag; ]
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft