//============================================================================= // // le_utils.mel - handy utilities for uses throughout the level editor code // //============================================================================= //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // returns "short" name of scene object global proc string le_short_name (string $name) { string $short_name[] = `ls -shortNames $name`; return $short_name[0]; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // returns child global proc string le_child (string $transform) { string $objs[] = `listRelatives -children -fullPath $transform`; if (size ($objs)) return $objs[0]; return ""; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // returns type (of child) proc string le_get_type (string $transform) { string $objs[] = `listRelatives -children -fullPath $transform`; if (size ($objs)) return `nodeType $objs[0]`; return `nodeType $transform`; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // retrieves the "LeEntity" attribute from an entity global proc string le_get_attributes (string $thing) { string $attr = ""; string $attr_names[]; string $name; string $names[] = `ls -l $thing`; int $num = 0; // check in case more than one object with the same name for ($name in $names) { $attr_names = `listAttr -userDefined -string "LeEntity" $name`; if ($attr_names[0] != "") { $attr = getAttr ($name + ".LeEntity"); $num++; } } if ($num > 1) { for ($name in $names) warning $name; warning ("Repeated le object name: " + $thing); $attr = ""; } return $attr; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Parses attribute into params/values pairs global proc string[] le_pairs_from_attr (string $attr) { string $block; string $pair[2]; string $blocks[]; string $pairs[]; int $i, $index; tokenize $attr ";" $blocks; for ($block in $blocks) { tokenize $block "=" $pair; if (size ($pair) > 2) { for ($i=1; $i<=size($block); $i++) { if (`substring $block $i $i` == "=") break; } $index = `size ($block)`; $pair[1] = `substring $block ($i+1) $index`; } $index = size ($pairs); $pairs [$index] = $pair[0]; $pairs [$index + 1] = $pair[1]; } return $pairs; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Locates parameter in pairs array and returns parameter's data global proc string le_find_param_in_pairs (string $pairs[], string $param) { int $i, $len = size ($pairs); for ($i=0; $i<$len; $i+=2) { if ($pairs[$i] == $param) break; } if ($i >= $len) return ""; else return $pairs[$i+1]; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Locates parameter in attribute string global proc string le_find_param_in_attr (string $attr, string $param) { string $pairs[] = le_pairs_from_attr ($attr); return (le_find_param_in_pairs ($pairs, $param)); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Parses attribute blocks and returns appropriate values global proc string[] le_values_from_pairs (string $pairs[], string $param) { int $i, $len = size ($pairs); string $values[]; for ($i=0; $i<$len; $i+=2) { if ($pairs[$i] == $param) { // tokenize $pairs[$i+1] "," $values; // because of the ,, case not returning null, here's my tokenize: int $index = 0; string $char; for ($j=1; $j<=size($pairs[$i+1]); $j++) { $char = `substring $pairs[$i+1] $j $j`; if ($char == ",") $index++; else $values[$index] = $values[$index] + $char; } break; } } return $values; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // applies the "LeEntity" attribute to an entity global proc le_apply_attributes (string $thing, string $attr) { string $attr_names[]; $attr_names = `listAttr -userDefined -string "LeEntity" $thing`; if ($attr_names[0] == "") addAttr -dataType "string" -longName "LeEntity" $thing; setAttr -type "string" ($thing + ".LeEntity") $attr; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Parses attribute blocks and sets appropriate values // (also creates param if it doesn't already exist) // Upon entry: $thing -> le entity // $param -> target parameter to change // $data -> data separated by commas (no trailing semicolon) global proc le_set_attr_from_param (string $thing, string $param, string $data) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $values[]; int $i, $len = size ($pairs); int $found_flag = false; $attr = $pairs[0]; for ($i=2; $i<$len; $i+=2) { if ($pairs[$i] == $param) // found it, save it and mark it { $pairs[$i+1] = $data; $found_flag = true; } $attr += ";" + $pairs[$i] + "=" + $pairs[$i+1]; } // we didn't find it, create it if ($found_flag == false) $attr += ";" + $param + "=" + $data; le_apply_attributes ($thing, $attr); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& proc float[] le_strings_to_floats (string $values[]) { float $fvalues[]; int $i; int $num = size ($values); for ($i=0; $i<$num; $i++) { $fvalues[$i] = ($values[$i]); } return $fvalues; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // this function retrieves: // 1. the current selection, or // 2. the current camera focus global proc float[] le_get_focus () { int $i; float $bb[6], $bb2[6]; float $pos[3] = { 0, 0, 0 }; float $dim[3]; string $sel[]; int $sel_size; // what is selected $sel = `ls -sl`; $sel_size = `size ($sel)`; if ($sel_size) { // on top of current selection $bb = `xform -ws -bb -query $sel[0]`; for ($i = 1; $i < $sel_size; $i ++) { $bb2 = `xform -ws -bb -query $sel[$i]`; if ($bb[0] > $bb2[0]) $bb[0] = $bb2[0]; if ($bb[1] > $bb2[1]) $bb[1] = $bb2[1]; if ($bb[2] > $bb2[2]) $bb[2] = $bb2[2]; if ($bb[3] < $bb2[3]) $bb[3] = $bb2[3]; if ($bb[4] < $bb2[4]) $bb[4] = $bb2[4]; if ($bb[5] < $bb2[5]) $bb[5] = $bb2[5]; } $pos[0] = ($bb[0] + $bb[3]) * 0.5; $pos[1] = $bb[4]; $pos[2] = ($bb[2] + $bb[5]) * 0.5; } else { // on look-at point of current camera $camera = `lookThru -query`; if ($camera != "") $pos = `camera -query -wci $camera`; } return $pos; } // this places the thing "on top" of pos global proc le_place_thing (string $thing, float $pos[]) { float $bb[6], $dim[3]; // placing thing $bb = `xform -os -bb -query $thing`; $dim[0] = $bb[3] - $bb[0]; $dim[1] = $bb[4] - $bb[1]; $dim[2] = $bb[5] - $bb[2]; xform -os -pivots 0 0 0 $thing; move -spr $pos[0] $pos[1] $pos[2] $thing; } /////////////////////////////////////////////////////////////////////////////////////////////////////////// // clears main dialog layout of controls global proc le_clear_layout () { global string $le_dialog_name; global string $le_root_layout; int $cwidth; deleteUI -layout $le_root_layout; setParent ($le_dialog_name); $cwidth = (`window -query -width $le_dialog_name`) - 12; rowColumnLayout -parent $le_dialog_name -numberOfColumns 1 -columnWidth 1 $cwidth -columnSpacing 1 4 $le_root_layout; } /////////////////////////////////////////////////////////////////////////////////////////////////////////// // parses a layout containing dialog controls // and adds the values to an attribute string global proc string le_parse_layout (string $attr, string $layout) { string $child, $children[]; string $s, $subchildren[]; string $postfix; $children = `layout -query -childArray $layout`; for ($child in $children) { if (($postfix = get_trailing_string ($child, "type_")) != "") { $attr += "type=" + $postfix + ";"; } else if (($postfix = get_trailing_string ($child, "groupLayout_")) != "") { $subchildren = `layout -query -childArray $child`; $attr += "group=" + $postfix + ";"; $attr = le_parse_layout ($attr, $subchildren[0]); $attr += "/group;"; } else if (($postfix = get_trailing_string ($child, "checkBoxLayout_")) != "") { int $first = true; $attr += $postfix + "="; $subchildren = `layout -query -childArray $child`; for ($s in $subchildren) { if (($postfix = get_trailing_string ($s, "checkBox_")) != "") { if (`checkBox -query -value $s`) { if (!$first) $attr += ","; $first = false; $attr += $postfix; } } } $attr += ";"; } else if (($postfix = get_trailing_string ($child, "radioButtonLayout_")) != "") { $attr += $postfix + "="; $subchildren = `layout -query -childArray $child`; for ($s in $subchildren) { if (($postfix = get_trailing_string ($s, "radioButton_")) != "") { if (`radioButton -query -select $s`) { $attr += $postfix; break; } } } $attr += ";"; } else if (($postfix = get_trailing_string ($child, "attrFieldGrp_")) != "") { int $i; float $values[]; string $attribute; $attr += $postfix + "="; $attribute = `attrFieldGrp -query -attribute $child`; if ($attribute != "") { $values = `getAttr $attribute`; $attr += $values[0]; for ($i = 1; $i < size ($values); $i++) $attr += "," + $values[$i]; } $attr += ";"; } else if (($postfix = get_trailing_string ($child, "attrField_")) != "") { int $i; float $values[]; string $attribute; $attr += $postfix + "="; $attribute = `attrField -query -attribute $child`; if ($attribute != "") { $values = `getAttr $attribute`; $attr += $values[0]; for ($i = 1; $i < size ($values); $i++) $attr += "," + $values[$i]; } $attr += ";"; } else if (($postfix = get_trailing_string ($child, "floatLayout_")) != "") { int $first = true; float $value; $attr += $postfix + "="; $subchildren = `layout -query -childArray $child`; for ($s in $subchildren) { if (get_trailing_string ($s, "float_") != "") { $value = `floatField -query -value $s`; if (!$first) $attr += ","; $first = false; $attr += $value; } } $attr += ";"; } else if (($postfix = get_trailing_string ($child, "intLayout_")) != "") { int $first = true; int $value; $attr += $postfix + "="; $subchildren = `layout -query -childArray $child`; for ($s in $subchildren) { if (get_trailing_string ($s, "int_") != "") { $value = `intField -query -value $s`; if (!$first) $attr += ","; $first = false; $attr += $value; } } $attr += ";"; } else if (($postfix = get_trailing_string ($child, "stringLayout_")) != "") { int $first = true; $attr += $postfix + "="; $subchildren = `layout -query -childArray $child`; for ($s in $subchildren) { if (get_trailing_string ($s, "textField_") != "") { string $value = `textField -query -text $s`; if (!$first) $attr += ","; $first = false; $attr += $value; } else if (get_trailing_string ($s, "textScrollList_") != "") { string $value, $values[] = `textScrollList -query -allItems $s`; for ($value in $values) { if (!$first) $attr += ","; $first = false; $attr += $value; } } } $attr += ";"; } } return $attr; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // check if namespace exists global proc int le_check_namespace (string $ns) { namespace -set ":"; string $b[] = `namespaceInfo -lon`; string $c; int $ret_val = false; for ($c in $b) { if ($c == $ns) { $ret_val = true; break; } } return ($ret_val); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // delete all objects in a namespace and the namespace itself global proc le_delete_namespace (string $ns) { string $ns_save, $name, $names[]; // all namespace names are absolute, add ':' to make sure $ns_save = ":" + `namespaceInfo -currentNamespace`; // set new namespace (add ':' to make it absolute) $ns = ":" + $ns; namespace -set ($ns); // process all sub-namespaces $names = `namespaceInfo -lon`; for ($name in $names) le_delete_namespace ($name); // process object is this namespace $names = `namespaceInfo -listNamespace`; for ($name in $names) { if (`objExists $name`) delete $name; } namespace -set $ns_save; namespace -rm ($ns); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // delete all ref_ namespaces global proc le_delete_all_ref_namespaces() { namespace -set ":"; string $all_ns[] = `namespaceInfo -lon`; string $ns, $ms; for ($ns in $all_ns) { $ms = `match "ref_" $ns`; if (`strcmp $ms "ref_"` == 0) { le_delete_namespace ($ns); } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // unparent all objects in ref_ namespaces to a unique dummy node global proc le_unparent_all_ref_namespaces() { namespace -set ":"; string $all_ns[] = `namespaceInfo -lon`; string $ns, $ms, $ref_group; for ($ns in $all_ns) { $ms = `match "ref_" $ns`; if (`strcmp $ms "ref_"` == 0) { $ref_group = ($ns + ":" + $ns); if (`objExists $ref_group`) parent -world $ref_group; } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // deselect all objects (keep transforms and display layers) // and throw away all ref_ namespace objs and other global proc le_deselect_unwanted_objects() { string $selection[] = `ls -selection`; string $obj, $ms; select -clear; for ($obj in $selection) { $ms = `nodeType $obj`; if ($ms != "transform" && $ms != "displayLayer") continue; $ms = `match ":" $obj`; if (`strcmp $ms ":"` != 0) select -add $obj; } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // gets topmost group node of object in given namespace global proc string le_get_group_node (string $ns) { namespace -set (":" + $ns); string $b[] = `namespaceInfo -ls`; string $c, $d; string $tokens[]; for ($c in $b) { $d = `objectType $c`; if ($d == "transform") { $tokens = `listRelatives -f -p $c`; tokenize $tokens[0] "|" $tokens; break; } } namespace -set ":"; return $tokens[0]; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // gets unique reference namespace (for imported items) global proc string le_get_unique_namespace() { namespace -set ":"; string $b[] = `namespaceInfo -lon`; string $c; string $d; int $num; int $high_num = 0; for ($c in $b) { $d = `substring $c 1 4`; if ($d == "ref_") { $d = `substring $c 5 10`; $num = ($d); if ($num > $high_num) $high_num = $num; } } return ("ref_" + ($high_num+1)); } /////////////////////////////////////////////////////////////////////////////// // exporter functions // converts euler to quat proc string[] le_euler2quat (string $values[]) { float $euler[3]; float $quat[4]; $euler[0] = $values[0]; $euler[1] = $values[1]; $euler[2] = $values[2]; $quat = Euler2Quat ($euler); $values[0] = $quat[0]; $values[1] = $quat[1]; $values[2] = $quat[2]; $values[3] = $quat[3]; return $values; } //***************************************************************************** // converts a path to a series of knots proc string[] le_path2knots (string $path) { string $type = le_get_type ($path); float $cv[3]; string $line[]; if ($type == "nurbsCurve") { int $i, $ncv = `getAttr ($path + ".degree")` + `getAttr ($path + ".spans")`; string $info = `createNode curveInfo`; // print ($ncv + ", " + $path + ", " + le_child ($path) + "\n"); connectAttr (le_child ($path) + ".worldSpace") ($info + ".inputCurve"); for ($i = 0; $i < $ncv; $i++) { $cv = `getAttr ($info + ".controlPoints[" + $i + "]")`; $line [$i*3 + 0] = $cv[0]; $line [$i*3 + 1] = $cv[1]; $line [$i*3 + 2] = $cv[2]; } delete $info; } return $line; } //***************************************************************************** // converts a path to 2 knots proc string[] le_path2line (string $path) { string $type = le_get_type ($path); float $cv[3]; string $line[]; int $index; if ($type == "nurbsCurve") { string $info = `createNode curveInfo`; // print ($ncv + ", " + $path + ", " + le_child ($path) + "\n"); connectAttr (le_child ($path) + ".worldSpace") ($info + ".inputCurve"); $index = `getAttr ($path + ".minValue")`; $cv = `getAttr ($info + ".controlPoints[" + $index + "]")`; $line [0] = $cv[0]; $line [1] = $cv[1]; $line [2] = $cv[2]; $index = `getAttr ($path + ".maxValue")`; $cv = `getAttr ($info + ".controlPoints[" + $index + "]")`; $line [3] = $cv[0]; $line [4] = $cv[1]; $line [5] = $cv[2]; delete $info; } return $line; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_delete_all_layers() { le_delete_all_ref_namespaces(); // ping the layers updateLayersByType ("Display"); select -cl; if (`layerButton -exists "Objects"` ) { select -add `editDisplayLayerMembers -fn -q Objects`; delete Objects; } if (`layerButton -exists "Zones"` ) { select -add `editDisplayLayerMembers -fn -q Zones`; delete Zones; } if (`layerButton -exists "AI"` ) { select -add `editDisplayLayerMembers -fn -q AI`; delete AI; } if (`layerButton -exists "Cameras"` ) { select -add `editDisplayLayerMembers -fn -q Cameras`; delete Cameras; } string $sel[]; // what is selected $sel = `ls -sl`; if (`size ($sel)` != 0) delete; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_init_layers() { le_delete_all_layers(); createDisplayLayer -e -n Objects; createDisplayLayer -e -n Cameras; setAttr "Cameras.color" 6; createDisplayLayer -e -n AI; setAttr "AI.color" 13; le_create_zone_layer(); le_fix_workspace(); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_create_layers() { // ping the layers updateLayersByType ("Display"); if (`layerButton -exists "Objects"` == 0) createDisplayLayer -e -n Objects; if (`layerButton -exists "Cameras"` == 0) { createDisplayLayer -e -n Cameras; setAttr "Cameras.color" 6; } if (`layerButton -exists "AI"` == 0) { createDisplayLayer -e -n AI; setAttr "AI.color" 13; } le_create_zone_layer(); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_create_zone_layer() { if (`layerButton -exists "Zones"` == 0) { createDisplayLayer -e -n Zones; setAttr "Zones.shading" 0; setAttr "Zones.color" 20; } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc string le_remove_commas (string $data) { string $prev_data; // get rid of commas while ($data != $prev_data) { $prev_data = $data; $data = `substitute "," $prev_data "_"`; } return $data; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Check and return a loaded instance of object type global proc string le_find_ref_instance (string $path) { string $objs[] = `editDisplayLayerMembers -fn -q Objects`; string $obj, $attr, $pairs[], $values[], $ref_obj, $ref_zone; int $found = 0; for ($obj in $objs) { $attr = le_get_attributes ($obj); if ($attr != "") { $pairs = le_pairs_from_attr ($attr); switch ($pairs[0]) { case "object": case "sound_object": case "vector_field": $values = le_values_from_pairs ($pairs, "path"); if ($values[1] == $path) { $ref_obj = $values[0] + ":" + $values[0]; if (`objExists $ref_obj`) { $ref_zone = $values[0] + ":zone"; $values = le_values_from_pairs ($pairs, "zone"); // make sure it has an original zone if (`objExists $ref_zone` && $values[0] == $ref_zone) $found = 1; } } break; case "world_object": $values = le_values_from_pairs ($pairs, "path"); if ($values[1] == $path) { $ref_obj = $values[0] + ":" + $values[0]; if (`objExists $ref_obj`) $found = 1; } break; } } if ($found == 1) break; } if ($found == 1) return ($ref_obj); else return (""); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Copy currently select objects global proc le_copy_selected_objects() { string $all[], $sel, $attr, $items[], $dup, $del; string $pairs[], $path[], $new_sel[]; $all = `ls -selection -long`; select -clear; // see if we need to get the 'real' node for ($sel in $all) { // find object that is a level-editor entity $attr = le_get_attributes ($sel); $pairs = le_pairs_from_attr ($attr); if ($attr != "" && $pairs[0] != "header" && $pairs[0] != "char_cam") // found one, now let's copy it { $new_sel = `ls -selection -long`; $items = `duplicate -rr $sel`; $dup = $items[0]; $attr = le_get_attributes ($dup); $pairs = le_pairs_from_attr ($attr); select $dup; if ($pairs[0] == "zone") layerEditorAddObjects Zones; else if ($pairs[0] == "camera") layerEditorAddObjects Objects; else if ($pairs[0] == "path") { $path = le_values_from_pairs ($pairs, "type"); if ($path[0] == "cam_path") layerEditorAddObjects Cameras; else layerEditorAddObjects AI; } else { $items = `listRelatives -fullPath -children $dup`; for ($del in $items) delete $del; // wipe the zone ref le_set_attr_from_param ($dup, "zone", ""); // get ref and path $path = le_values_from_pairs ($pairs, "path"); // this should replace the ref zone with a new one le_load_ref_object ($dup, $path[0], $path[1]); // check if this is a ref object $path = le_values_from_pairs ($pairs, "zone"); if ($path[0] != "" && `match ":" $path[0]` == "") { // copy the zone $items = `duplicate -rr $path[0]`; parent $items[0] $dup; le_set_attr_from_param ($dup, "zone", $items[0]); // fix the zone's reference le_set_attr_from_param ($items[0], "object", $dup); } } select $new_sel; select -add $dup; setToolTo "moveSuperContext"; } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc int le_is_it_a_number (string $data) { if ($data == "0") return (1); if ($data == "") return (0); if (`match "[\-0123456789\.]+" $data` == $data) return (1); else return (0); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc int le_convert_string_to_int (string $data) { if ($data == "0" || $data == "") return (0); if (`match "[\-0123456789\.]+" $data` == $data) return ($data); else return (0); }