HP Forums
how to remove string? - 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: how to remove string? (/thread-10834.html)



how to remove string? - Richard - 05-31-2018 06:44 PM

hello boys,

how could i remove the string

example:
"hp_prime" >>>> hp_prime


RE: how to remove string? - cyrille de brébisson - 06-01-2018 04:56 AM

Hello,

When you see "hp_prime", it means that you have a string object that contains the text hp_prime.
The double quote is not part of the string... it is an indicator... So you can not "remove" it...

If what you want to do is display the content of the string on the screen, depending on what you want to do exactly, you could use the textout_p or print functions...

If you want to convert that string into another object (for example, if your string contains the name of a variable and that you want to get the content of this variable), you could use expr...

Please tell us more...

Cyrille


RE: how to remove string? - Richard - 06-01-2018 06:48 AM

I CAN NOT MODIFY THE USER VARIABLES

[img]https://ibb.co/dFjTNd https://ibb.co/jPLPvy https://ibb.co/jfMWay https://ibb.co/gMhtoJ https://ibb.co/jSRa2d https://ibb.co/n2W8Nd[/img]


RE: how to remove string? - Richard - 06-01-2018 04:55 PM

CREATE USER VARIABLES
[Image: 20180601114656.png]
MY PROGRAM: edit the objects in the lists
DAT1;
DAT2;

EXPORT PREGUNTA(Y,D)
BEGIN

PRINT;
DAT1:=EXPR("YEAR_"+Y+"_DAY_"+D); // LIST
DAT2:=EVAL("'YEAR_"+Y+"_DAY_"+D+"'"); // NAME LIST

PRINT(DAT2)+PRINT(DAT1);
wait(3);

EDITLIST(DAT1);

END;

example
[Image: 20180601114823.png]

[Image: 20180601115440.png]

[Image: 20180601115007.png]

[Image: 20180601115029.png]

[Image: 20180601115042.png]

why the changes made in the list YEAR_1999_DAY_2 are not kept?


RE: how to remove string? - Richard - 06-01-2018 08:54 PM

Code:
EXPORT LIST_1:={1,2,3}; 
EXPORT LIST_2:={"A","B","C"};

ID;
NUMBER;
VAR;

EXPORT global2()
BEGIN

NUMBER:=1;
ID:=EXPR("'LIST_"+NUMBER+"'");  // ID  =LIST_1
VAR:=EXPR("'LIST_"+NUMBER+"'"); // VAR =LIST_1

LIST_2▶VAR;

PRINT;
PRINT(ID+"=");
PRINT(VAR);

END;


another example
Why can not the global variables be modified from the program?


RE: how to remove string? - Didier Lachieze - 06-01-2018 09:27 PM

(06-01-2018 08:54 PM)Richard Wrote:  another example
Why can not the global variables be modified from the program?

Is this what you want to do :
Code:
EXPORT LIST_1:={1,2,3}; 
EXPORT LIST_2:={"A","B","C"};

ID;
NUMBER;
VAR;

EXPORT global2()
BEGIN

NUMBER:=1;
EXPR("ID:=LIST_"+NUMBER);      // ID  =LIST_1
EXPR("VAR:=LIST_"+(NUMBER+1)); // VAR =LIST_2

//LIST_2▶VAR;

PRINT;
PRINT(STRING(ID)+"=");
PRINT(VAR);

END;



RE: how to remove string? - Richard - 06-02-2018 04:49 PM

Code:
EXPORT LIST_1:={1,2,3}; 

ID;
NUMBER;
VAR;

EXPORT CHANGE()
BEGIN

NUMBER:=1;
ID:=EXPR("'LIST_"+NUMBER+"'");  // ID  =LIST_1
VAR:=EXPR("'LIST_"+NUMBER+"'"); // VAR =LIST_1

EDITLIST(EVAL(ID)); // LIST_1:={ 1,2,3 } CHANGE LIST_1:{100,200,300}

// CHECK THIS GLOBAL VARIABLE IN MEM> USER VARIABLES> LIST_1
// You will see that the change is not saved
END;



RE: how to remove string? - Richard - 06-02-2018 04:49 PM

Code:
EXPORT LIST_1:={1,2,3}; 

ID;
NUMBER;
VAR;

EXPORT CHANGE()
BEGIN

NUMBER:=1;
ID:=EXPR("'LIST_"+NUMBER+"'");  // ID  =LIST_1
VAR:=EXPR("'LIST_"+NUMBER+"'"); // VAR =LIST_1

EDITLIST(EVAL(ID)); // LIST_1:={ 1,2,3 } CHANGE LIST_1:{100,200,300}

// CHECK THIS GLOBAL VARIABLE IN MEM> USER VARIABLES> LIST_1
// You will see that the change is not saved
END;



RE: how to remove string? - Didier Lachieze - 06-02-2018 05:37 PM

(06-02-2018 04:49 PM)Richard Wrote:  
Code:
EXPORT LIST_1:={1,2,3}; 

ID;
NUMBER;
VAR;

EXPORT CHANGE()
BEGIN

NUMBER:=1;
ID:=EXPR("'LIST_"+NUMBER+"'");  // ID  =LIST_1
VAR:=EXPR("'LIST_"+NUMBER+"'"); // VAR =LIST_1

EDITLIST(EVAL(ID)); // LIST_1:={ 1,2,3 } CHANGE LIST_1:{100,200,300}

// CHECK THIS GLOBAL VARIABLE IN MEM> USER VARIABLES> LIST_1
// You will see that the change is not saved
END;

I don't know why your program ends up editing Ans instead of LIST_1, maybe Cyrille can provide some insights on how parameters are managed for EDITLIST.

However here is a way to edit the list defined by ID:
Code:
NUMBER:=1;
ID:="LIST_"+NUMBER;  // ID  ="LIST_1"

EXPR("EDITLIST("+ID+")"); // LIST_1:={ 1,2,3 } CHANGE LIST_1:{100,200,300}



RE: how to remove string? - roadrunner - 06-03-2018 10:23 AM

Hello,

It also works if you put ID in single quotes, like this:

EDITLIST(EVAL('ID')); // LIST_1:={ 1,2,3 } CHANGE LIST_1:{100,200,300}

-road


RE: how to remove string? - Tim Wessman - 06-03-2018 11:58 PM

Don't forget that EDITLIST returns the edited list - it doesn't automatically store it into the variable. SO you need to do MYVAR:=EDITLIST(...) to keep your changes...


RE: how to remove string? - Richard - 06-04-2018 01:29 PM

Thank you so much guys

I had broken my head trying to solve this, the truth that I am a novice with this calculator

Thank you