/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ fun deleteOb(inst)= 0;; fun cbInChar(inst, from, action, param, reply, p)= let p -> [sep occurence order] in let strfind2List param sep 0 -> lpos in let sizelist lpos -> size in let "" -> start in let "" -> end in ( if (lpos == nil || size < occurence) then set start = param else let nth_list lpos (if order == 0 then (occurence - 1) else (size - occurence)) -> pos in let pos + (max 1 (strlen sep)) -> sepend in ( set start = substr param 0 pos; set end = substr param sepend ((strlen param) - sepend); ); SendPluginEvent inst "Start" start nil; SendPluginEvent inst "End" end nil; ); 0;; fun cbInNb(inst, from, action, param, reply, p)= let p -> [number order] in let strlen param -> len in let "" -> start in let "" -> end in ( if (len <= number) then set start = param else let if order == 0 then number else len - number -> idx in ( set start = substr param 0 idx; set end = substr param idx (len - idx); ); SendPluginEvent inst "Start" start nil; SendPluginEvent inst "End" end nil; ); 0;; fun newOb(inst)= let atoi (getPluginInstanceParam inst "mode") -> mode in let if (mode == nil) then 0 else mode -> mode in let (getPluginInstanceParam inst "sep") -> sep in let if (sep == nil) then ";" else sep -> sep in let atoi (getPluginInstanceParam inst "occurence") -> occurence in let if (occurence == nil) then 1 else occurence -> occurence in let atoi (getPluginInstanceParam inst "order") -> order in let if (order == nil) then 0 else order -> order in let atoi (getPluginInstanceParam inst "number") -> number in let if (number == nil) then 1 else number -> number in ( if (mode == 0) then PluginRegisterAction inst "In" mkfun6 @cbInChar [sep occurence order] else PluginRegisterAction inst "In" mkfun6 @cbInNb [number order]; setPluginInstanceCbDel inst @deleteOb; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;