Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 i need help! i need to put data into arrays in a loop
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
r0ssar00




PostPosted: Sat Oct 16, 2004 4:08 pm   Post subject: i need help! i need to put data into arrays in a loop

a little bit of a problem...

the code is this and the required files are already opened with get access
code:

%there is stuff before this!
var a_storage, b_storage : array 1 .. numberOfUsers of int
var count:int:=1
loop
    exit when count = numberOfUsers
    count += 1
    get : fileNmb, a_storage (count)
end loop
count := 1
loop
    exit when count = numberOfUsers
    count += 1
    get : fileNmb2, pass_storage (count)
end loop
%there is stuff after this

my problem is that it always errs on line 6, can anyone help?
err = "invalid integer input"
basically what im doing is taking info line by line from one file and
putting it into a_storage and then taking info line by line from a second
file and putting it into b_storage
the count is so that i can stop the get when i reach the max
numberOfUsers which is whatever i specify
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Sat Oct 16, 2004 5:53 pm   Post subject: (No subject)

You need to show us all of the code.
r0ssar00




PostPosted: Mon Oct 18, 2004 9:33 am   Post subject: (No subject)

all you need is that because that is the whole part that relates to the problem, everything else works, if i were to give you the rest of the code, my idea would not be as original, all you need is that part, i do not plan o selling this or anything, i just want this to remain original until i release it, i hope thats alright with evry1, even if i were to post it in this post, i couldn't, the code is at home and im writing this at school
Tony




PostPosted: Mon Oct 18, 2004 9:49 am   Post subject: (No subject)

Quote:

var count:int:=1
loop
exit when count = numberOfUsers
count += 1
get : fileNmb, a_storage (count)


1 + 1 = 2 !
that's the first entry you read... 2nd Confused that might be a problem
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DanShadow




PostPosted: Mon Oct 18, 2004 10:50 am   Post subject: (No subject)

Ive seen problems like that before...Id suggest just instead of reading integers, read string's. Then use the 'strint' command when you have read those...you can transfer them to integers.
code:

%there is stuff before this!
var a_storage, b_storage : array 1 .. numberOfUsers of int
var temp_storage_a,temp_storage_b:array 1..numberOfUsers of string
var count:int:=1
loop
    exit when count = numberOfUsers
    count += 1
    get : fileNmb, temp_storage_a(count)
    if strintok(temp_storage_a(count)) then
    a_storage(count):=strint(temp_storage_a(count))
end if
end loop
count := 1
loop
    exit when count = numberOfUsers
    count += 1
    get : fileNmb2, pass_storage (count)
end loop
%there is stuff after this

Ok....I cant do the second loop, as I dont know if 'pass_storage' is an integer or string. And yes, you should post the rest of your code if you want it accurately examined. But if your afraid of somebody stealing your code, PM one of the Turing Moderators (aka me,Asian Sensation, etc.) with your code, and your question. (Note: DO NOT ask for the answers. I cant stress that enough, lol. Ask 'how' you might come to a conclusion, or for help. I know you didnt ask for the answers, but im just pointing that out.) And believe, none of the moderators of CompSci would have any purpose of stealing your code. (As they could create better. Wink )
Anyways, I hope the 'strint' idea works for you, good luck.
r0ssar00




PostPosted: Tue Oct 19, 2004 9:45 am   Post subject: (No subject)

sorry, typo: pass_storage is supposed to b_storage, but i would do the same thing as in a_storage, correct, i hope so
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: