Bulls and cows: Difference between revisions

m
Line 7,475:
VBS does'nt have a continue so i used the classic do loop inside do loop in the main program
<lang vb>
dim p,c
randomize timer
fail=array("Wrong number of chars","Only figures 0 to 9 allowed","Two or more figures are the same")
p=dopuzzle()
wscript.echo "Bulls and Cows. Guess my 4 figure number!"
Line 7,483:
wscript.stdout.write vbcrlf & "your move ": s=trim(wscript.stdin.readline)
c=checkinput(s)
if not isarray (c) then wscript.stdout.write "Wrongfail(c) input":exit do
bu=c(0)
wscript.stdout.write "bulls: " & c(0) & " | cows: " & c(1)
Line 7,504:
dim c(10)
bu=0:co=0
if len(s)<>4 then checkinput=-1 0:exit function
for i=1 to 4
b=mid(s,i,1)
if c(ascinstr("0123456789",b)-48)<>=0 then checkinput=-1 :exit function
if instrc(asc("0123456789",b)=-48)<>0 then checkinput=-12 :exit function
c(asc(b)-48)=1
if instr("0123456789",b)=0 then checkinput=-1 :exit function
for j=1 to 4
if asc(b)=asc(mid(p,j,1)) then
Line 7,518:
checkinput=array(bu,co)
end function
 
</lang>