Computer Science Canada

question bout ERROR

Author:  Poland13 [ Wed Jan 07, 2004 6:10 pm ]
Post subject:  question bout ERROR

var cardz : array 1..13 of string:= init("2,3,4,5,6,7,8,9,T,J,Q,K,A")

the error is 2 few inital values

Author:  Thuged_Out_G [ Wed Jan 07, 2004 6:14 pm ]
Post subject: 

try changing it to 1..12 instead of 1..13...that might help, but im not positive Confused lol

EDIT: ignore my post, ive never used an array that way, so i was not sure....ive only used for loops to put info into my arrays Confused

Author:  JayLo [ Wed Jan 07, 2004 6:15 pm ]
Post subject: 

it's because you have to put each individual string item in quotes, divided by commas.

code:
var cardz : array 1..13 of string:= init("2","3","4","5","6","7","8","9","T","J","Q","K","A")

Author:  Tony [ Wed Jan 07, 2004 6:15 pm ]
Post subject: 

eh... no... you initialize cardz(1) to be that entire string. You need to use separate values... meaning
[code]
init("1","2"...."A")

Author:  Poland13 [ Wed Jan 07, 2004 6:16 pm ]
Post subject: 

thanks alot i couldn't figure it out

Author:  Poland13 [ Wed Jan 07, 2004 6:24 pm ]
Post subject: 

can someone help me out bit with this code its suppose to egnerate a random deck of cards ne help would be appreacated

var deck: array 1..52 of string
var cardz: array 1..13 of string:= init("2","3","4","5","6","7","8","9","T","J","Q","K","A")
var suit : array 1..4 of string := init("C","D","S","H")
for x: 1..4
for y: 1..13
deck(cardz):=cardz(1)+ suit(1)
cardz:=cardz +1
end for
end for

Author:  shorthair [ Wed Jan 07, 2004 6:28 pm ]
Post subject: 

you never actually tell the program to output the cards , thats the problem

Author:  Poland13 [ Wed Jan 07, 2004 6:34 pm ]
Post subject: 

deck(cardz):=cardz(1)+ suit(1)

this is an error subscript of deck is wrong type


: