Can u help me plz.

Hi there, 1st , sorry about my bad english but i'm from mexico ^^

here's the question ...

i'm doing a program to analize an expretion, like ((44/12)*15)
when the program starts , it asks the user to 'press' the correct order of the equation(without the parentesis) 1 by 1, so everytime a caracter is readed , it's temp. saved on a variable (type string).
i can use the integer values saved there, but i can not do operations like plus, div, etc.., so dats my question ,

how can i assing integer values saved on a string variable into a string variable

example:

var1:string;
var2:integer;

write('character? ');
readln(var1); {i need to read it on a string variable because of the simbols , + , ^ , * , ... etc }


var2:=var1; {obviously,here's when error 25 appears}


i hope some1 can help me with this maybe 'dumb' question,

^^ thanx anyways , because of this excellent website



Comments

  • : Hi there, 1st , sorry about my bad english but i'm from mexico ^^
    :
    : here's the question ...
    :
    : i'm doing a program to analize an expretion, like ((44/12)*15)
    : when the program starts , it asks the user to 'press' the correct order of the equation(without the parentesis) 1 by 1, so everytime a caracter is readed , it's temp. saved on a variable (type string).
    : i can use the integer values saved there, but i can not do operations like plus, div, etc.., so dats my question ,
    :
    : how can i assing integer values saved on a string variable into a string variable
    :
    : example:
    :
    : var1:string;
    : var2:integer;
    :
    : write('character? ');
    : readln(var1); {i need to read it on a string variable because of the simbols , + , ^ , * , ... etc }
    :
    :
    : var2:=var1; {obviously,here's when error 25 appears}
    :
    :
    : i hope some1 can help me with this maybe 'dumb' question,
    :
    : ^^ thanx anyways , because of this excellent website
    :
    :
    :
    :
    hi!
    I find your question interesting,although I can`t find a solution for your problem.
    The error is in this line:var2:=var1;
    It is simply not possible that you assign an integer variable with a string value.It a type mischmash.
    I suggest that you store the nimbers in integer variables and the sybmols'+','-',etc in strings.then you can use if-then or case to comply the operation requested.
    Looking forward to hearing from you.
    li-zi

  • : Hi there, 1st , sorry about my bad english but i'm from mexico ^^
    :
    : here's the question ...
    :
    : i'm doing a program to analize an expretion, like ((44/12)*15)
    : when the program starts , it asks the user to 'press' the correct order of the equation(without the parentesis) 1 by 1, so everytime a caracter is readed , it's temp. saved on a variable (type string).
    : i can use the integer values saved there, but i can not do operations like plus, div, etc.., so dats my question ,
    :
    : how can i assing integer values saved on a string variable into a string variable
    :
    : example:
    :
    : var1:string;
    : var2:integer;
    :
    : write('character? ');
    : readln(var1); {i need to read it on a string variable because of the simbols , + , ^ , * , ... etc }
    :
    :
    : var2:=var1; {obviously,here's when error 25 appears}
    :
    :
    : i hope some1 can help me with this maybe 'dumb' question,
    :
    : ^^ thanx anyways , because of this excellent website

    If var1 is going to have non-numerical characters (like +, ^, *, etc), then you'll have to write a function to split that string so you can separate the numbers from the operators.

    Then to convert a string containing a number to an integer, you can use the Val() function.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion