Problem with strings and numbers

I everybody, I’m new to Navision (I have NF 2.6) and I have a problem! I have a string (and that string have only numbers on it), and I need multiply each position in that string by a diferent number. What I’m doing is: I store the result of COPYSTR in a ‘text’ variable with lenght (1) called var1, Like that: var1 := COPYSTR(mystring,1,1); Then I have a var2 (Integer) and I want put the value of var1 in var2, to make the operation, something like that: var2 := var1; result := var2 * 12; but I receive an error when I try assign the var1 to var2. Thank’s

hello, first step is fine, the second one that gives you the error needs to be modified… Navision does not allow you to pass one var simply to the other if the types are different, for passing a string var to any other type use EVALUATE: EVALUATE(var2,var1); Hope that helps. Saludos Nils

Thank’s Nils, that’s it. Work fine. Gratias!

Hi Adelino, From your description it looks to me like you are trying to calculate a checksum based on the numbers in the string. If that is what you are trying to do, then you could look at the STRCHECKSUM function as well. This performs a Modulus check on a string containing only numbers. Lars Strøm Valsted Head of Project and Analysis Columbus IT Partner A/S www.columbusitpartner.com

I Lars thank’s for your sugestion. I’m new to NF (2 weeks) and I don’t have any formation yet, so I’m trying to use my C++ and VB knowledge to program in C/AL. At that moment my questions maybe basic’s Thank’s

Adelino, We’ve all been beginners to Navision at some point in time, so we know your situation. You’ve come to the right place with your questions, so welcome and feel free to ask at any time :slight_smile: Lars Strøm Valsted Head of Project and Analysis Columbus IT Partner A/S www.columbusitpartner.com

Try changing the data type of var1 to Char, and setting var1 := mystring[i]. Char variables can be manipulated as integers; in particular you can subtract 48 (ASCII characters 0-9 begin at decimal 48) to obtain the value of the character.