HP Forums

Full Version: how to remove string?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello boys,

how could i remove the string

example:
"hp_prime" >>>> hp_prime
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
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?
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?
(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;
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;
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;
(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}
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
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...
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
Reference URL's