HP Forums

Full Version: How to control if a list isn't void?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi,
I've this code:

Code:

IF (SIZE(Long_Lat)==2) THEN long:= Long_Lat(1); lat:= Long_Lat(2);
  ELSE long:= →HMS(-14°30′40″); lat:= →HMS(37°55′55″); END;

I need a better way to control if the list Long_Lat {} is not void and has two elements with correct format: {-14°30′40″, 37°55′55″} (or almost two reals)...

thank you
Salvo
I would simply test (with "type()") if your HMS construct or your pair of reals belongs to DOM_SPECIALFLOAT or DOM_FLOAT, respectively (works in CAS).
(07-02-2015 01:32 AM)Helge Gabert Wrote: [ -> ]I would simply test (with "type()") if your HMS construct or your pair of reals belongs to DOM_SPECIALFLOAT or DOM_FLOAT, respectively (works in CAS).

I'll try, thank you!
When I tried it, I realized you need to convert into a string as well, i.e.

string(type(7°30'))==string(DOM_SPECIALFLOAT) returns 1.
(07-02-2015 02:20 PM)Helge Gabert Wrote: [ -> ]When I tried it, I realized you need to convert into a string as well, i.e.

string(type(7°30'))==string(DOM_SPECIALFLOAT) returns 1.

I want save into →HMS() format...
I'm using this in my astronomy program: the initial input asks to save coordinates, if the user chooses yes it saves into an exported var, otherwise it set a default couple of coordinates, then if the var exists, the program load the var into two fields and set two vars (lat, long)...

Maybe to control only for type it's enough (why someone should change a var exported by the program?), but...
Reference URL's