I have an NX Knowledge Fusion Check-Mate program to check if there are any Manual Dimension containing any type of number.
But the data type of the dimension is always a list of strings (I am only interested in the first position of the list).
If the string contained in the first position of the list can be converted to Number type, ie if the string is "200" the program must return true and append the dimension tag to a list, but if it is "22c" the program must return false.
I tried with the function MakeNumber(string), but this function only works if the string can be converted to Number. If the string is not a number the program crashes.
Thanks very much!
My dfa code of the checker function is that:
Checker function
(Any Uncached) do_check: @{ $dim_manual << mqc_askManualDimensions();
$dim_log <<loop
{
for $each in $dim_manual;
for $is_sleep is mqc_isSleepObject( $each );
for $is_condemned is mqc_isCondemnedObject( $each );
#I print the value i want to check
do ug_printvalue($each);
for $text is mqc_askDimensionManualText( $each );
do ug_printvalue(nth(0,$text));
#I check the type of the dimension content --> String
#If nth(0,$text) is Number type, typecheck returns true
#but always return false because nth(0,$text) is String type!
for $is_number is typecheck(nth(0,$text), Number);
do ug_printvalue($is_number);
do ug_printvalue(TypeName(nth(0,$text)));
#I try to convert the String in a Number. If the String can not be
#converted the program crashes!!
for $n is MakeNumber(nth(0,$text));
do ug_printvalue($n);
#I want to append in the error log only the manual dimensions that
#contains ONLY a number.
if (!$is_sleep & !$is_condemned & $is_number)
append {$each};
};
if !empty?( $dim_log ) Then
@{
$log_msg << @{If (log_msg:="") Then "" Else log_msg:+"~n";} +
mqc_sprintf("Found %s dimension(s) with manual text.", Stringvalue(Length($dim_log)));
ug_mqc_log( nth( log_type:, log_type_option: ), $dim_log, $log_msg );
}
Else donothing;
};
I found a solution. My dfa method that determines if a given string can be parsed as a number or not.
When this method is called in the do_check function of my dfa file the result can be stored in a loop variable like this: