
-----------------------------------
superben20
Wed Jan 06, 2016 10:12 pm

Help me with my code, I'm trying to get a specific integer from my .txt File
-----------------------------------
What is it you are trying to achieve?
I want to be able to change 1 specific integer from a .txt File that only has specific integers on a different line.


What is the problem you are having?
I kept on having problems saying that there is an illegal character in the string, but I want an integer, not a string. I want 1 specific integer changed, not all of them.


Describe what you have tried to solve this problem
Looking the Web, and trying everything that was posted on the Compsci website, none of them worked well enough


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




var badges, Badge : int
var temp : array 1 .. 3 of int
    open : badges, "Badges.txt", get
    get : badges, temp(1)
    close : badges
    put : temp(1)



Please specify what version of Turing you are using
Turing 4.1.1

-----------------------------------
Jeffmagma
Thu Jan 07, 2016 12:33 pm

Re: Help me with my code, I'm trying to get a specific integer from my .txt File
-----------------------------------
Get them as strings, then use  to check if its the number you want

-----------------------------------
superben20
Thu Jan 07, 2016 1:58 pm

Re: Help me with my code, I'm trying to get a specific integer from my .txt File
-----------------------------------
Ok, I tryed that, and it didn't work, it still says that there is an illegal character in the string:

var temp : array 1 .. 3 of int
var dummy : string
open : badges, "Badges.txt", get
    for i : 1 .. 3
    get : badges, dummy
    if strintok(dummy) then
        temp(i) := dummy
        close : badges
        open : badges, "Badges.txt", put
        put : badges, temp(i)
        end if
    end for

This is the code that I have, I know that it doesn't work because the error of the illegal character in the string.

-----------------------------------
Insectoid
Thu Jan 07, 2016 2:10 pm

RE:Help me with my code, I\'m trying to get a specific integer from my .txt File
-----------------------------------
strintok() only checks if the string can be converted to an integer. strint() does the actual conversion.
