HP Forums
Control (programmatically) if a list exist, otherwise create it - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Control (programmatically) if a list exist, otherwise create it (/thread-3897.html)



Control (programmatically) if a list exist, otherwise create it - salvomic - 05-18-2015 04:10 PM

hi all,
what's the simplest way to control (programmatically) if a list exist, otherwise create it (then edit it with EDITLIST)?

thank you
Salvo


RE: Control (programmatically) if a list exist, otherwise create it - mandresve - 05-18-2015 05:14 PM

(05-18-2015 04:10 PM)salvomic Wrote:  hi all,
what's the simplest way to control (programmatically) if a list exist, otherwise create it (then edit it with EDITLIST)?

thank you
Salvo

Hi Salvo,
Maybe you can use the length command to determine if a list is already created.

Code:

IF length(L1)==0 THEN
...
ELSE
...
END;

Just a tricky idea.


RE: Control (programmatically) if a list exist, otherwise create it - salvomic - 05-18-2015 05:26 PM

(05-18-2015 05:14 PM)mandresve Wrote:  
Code:

IF length(L1)==0 THEN
...
ELSE
...
END;

Just a tricky idea.

thank you,
I'm trying with variable flows (program for IRR): if flows doesn't exist my program gives "Error:unlatch control word" ... I dunno what it means...

Salvo


RE: Control (programmatically) if a list exist, otherwise create it - cyrille de brébisson - 05-19-2015 05:23 AM

Hello,

look at the TYPE and SIZE commands to test if a varaible is a list (type 6) and it's size.

use Solve.SOLVE rather than fsolve for the solving of the IRR, it probably will work better in this case as it will not call the CAS.

cyrille


RE: Control (programmatically) if a list exist, otherwise create it - salvomic - 05-19-2015 09:40 AM

(05-19-2015 05:23 AM)cyrille de brĂ©bisson Wrote:  Hello,
look at the TYPE and SIZE commands to test if a varaible is a list (type 6) and it's size.
use Solve.SOLVE rather than fsolve for the solving of the IRR, it probably will work better in this case as it will not call the CAS.
cyrille

thank you, Merci, Cyrille,
I'll try it this evening at home. If it works I'll be able to avoid to call CAS and could solve two problem in few rows of code.

Salvo

EDIT: however now I'm trying with solve() and not fsolve() and it works better also with the "11 element list" (2 results, but the first, the negative one has -1 added...), however in CAS Terminal gives the message "Warning, argument is not an equation, solving ...", in Home no message.

Instead, Solve.SOLVE() works in Home and CAS, but gives only one result...

Much better, however!