| 
					 
							
													 
							
						 
						
 
 | 
 | 
 
2007/2/11(Sun) 08:34:31|NO.5592 
pcbnet2で下のプログラムのように 
既にログインしている人の情報を得るために、 
conper(ログインしている全ての人数が代入されている)を送り、 
クライアントではその分だけ繰り返します。 
cntを送りcntgに代入。そして、name.cntg(その人の名前)に代入して 
mes命令で表示したのですが、 
例えばAとBが既にログインしていたとすると、 
A 
B 
と表示してほしいのですが、 
A0001Bと表示されてしまいます。 
これはなぜなんでしょうか。どこに問題があるのでしょうか。
  
サーバー側
	tcpputc conper-1,gas.sc
	repeat conper-1
	userc=strf("%04d",strlen(user.cnt))+user.cnt
	tcpputc cnt,gas.sc
	tcpput userc,gas.sc
	loop
クライアント側
	repeat
	tcpgetc conper,gas
	if stat=0:break
	await 1
	loop
	mes conper
	repeat conper
	tcpgetc cntg,gas
	tcpget size,5,gas
	size=int(size)
	tcpget name.cntg,size+1,gas
	size=""
	mes name.cntg
	loop
 
  
 |   
  
 
 | 
 | 
 
2007/2/12(Mon) 11:51:07|NO.5611 
一部抜き出しではなく、実際に不具合の起こる、最小のスクリプトを掲示してみてください。 
上のスクリプトでは、ぱっと見た感じでは問題なさそうです。 
 
 |   
  
| 
 | 
 
2007/2/12(Mon) 17:30:58|NO.5620 
クライアント側 
 
#include "pcbnet2.as"
	user="":pw="":size="":exi=0:adr="127.0.0.1":port=5030:nm="":mc=9
	arget="":conper=0:users="":pws="":sdim name,10:dim soc,10
         ;userは自分の名前,pwはパスワード,conperは自分以外のログインしている人
         ;nameは自分以外のログインしている人の名前
	objmode 0
*login
	cls
	pos 230,230:input user,200,30
	input pw,200,30
	pos 150,235:mes "ユーザー名"
	pos	150,260:mes "パスワード"
	objsize 100,30:pos 250,300:button "ログイン",*tuusin
stop
*tuusin
	if user="" or pw="":dialog "両方記入して下さい。",0,"忠告":goto *login
	cls
	tcpopen gas,adr,port
	repeat
	tcpiscon gas
	if stat=2:goto *miss
	if stat=1:break
	await 1
	loop
	users=strf("%04d",strlen(user))+user
	pws=strf("%04d",strlen(pw))+pw
	tcpput users,gas
	tcpput pws,gas
	size=int(size)
	repeat
	tcpgetc exi,gas
	if stat=0:break
	await 1
	loop
	if exi=0:tcpclose gas:dialog "ユーザー名またはパスワードが間違っています。",0,"失敗"
	if stat=1:user="":pw="":goto *login
	dialog "ログインしました。",0,"ログイン確認"
	goto *alexi
	stop
*miss
	dialog "サーバーが起動していないか、接続中にエラーが発生しました。",0,"警告"
	end
*alexi
	repeat
	tcpgetc conper,gas
	if stat=0:break
	await 1
	loop
	repeat conper
	tcpgetc cntg,gas
	tcpget size,5,gas
	size=int(size)
	tcpget name.cntg,size+1,gas
	size=""
	mes name.cntg
	loop
 
 
 
  |    |   
  
| 
 | 
 
2007/2/12(Mon) 17:37:36|NO.5621 
クライアント側 
 
#include "pcbnet2.as"
dim soc,10:dim gas,10:sdim user,10:sdim pw,10:sdim noteexi,10
sdim noteexig,10:dim arget,10:users=str(users):size=str(size)
tcpmake gbs,5030
repeat
repeat 10
sc=cnt
;soc.cntの値 0の時はそのcntにはログインされていない。
;1はログインしてある。2はログイン処理終了
;-1はログイン失敗
;conperはログインしている人数
if soc.cnt=0:gosub *wanda:if waits=0:continue
if soc.cnt=1:gosub *login
if soc.cnt=2:gosub *alexi
if soc.sc!0 or soc.sc=-1:gosub *conon
loop
await 1
loop
*wanda
tcpwait gbs:waits=stat
if waits=1:tcpaccept gas.sc,gbs:soc.sc=1
return
*login
repeat
tcpget size,5,gas.sc
if stat!0:break
await 1
loop
size=int(size)
tcpget user.sc,size+1,gas.sc
size=str(size)
tcpget size,5,gas.sc
size=int(size)
tcpget pw.sc,size+1,gas.sc
mes user.sc
mes pw.sc
size=str(size)
exist ""+user.sc+""+".txt"
if strsize!-1:exi=1
if strsize=-1:exi=0:soc.sc=-1
switch exi
case 1
notesel noteexi.sc
noteload ""+user.sc+""+".txt"
noteget noteexig.sc,0
switch pw.sc
case noteexig.sc
soc.sc=2
conper+
swbreak
default
exi=0
soc.sc=-1
swbreak
swend
swbreak
swend
tcpputc exi,gas.sc
soc.sc=2
return
*conon
tcpfail gas.sc
switch stat
case 1
soc.sc=0
user.sc=""
pw.sc=""
noteexi.sc=""
conper-
arget.sc=0
mes "gas."+sc
tcpclose gas.sc
gas.sc=0
swbreak
swend
return
*alexi
tcpputc conper-1,gas.sc
repeat conper-1
userc=strf("%04d",strlen(user.cnt))+user.cnt
tcpputc cnt,gas.sc
tcpput userc,gas.sc
loop
soc.sc=3
return
 
*alexiでわかったことはクライアント側で2回目のループの場合cntの値が受信できていないということです。
  
 
  |    |   
  
| 
 | 
 
2007/2/13(Tue) 05:42:04|NO.5656 
できるだけ不具合が出るなかで"最小"のスクリプトにしてください。 
長いと読む気がしない・・・ 
とりあえず、不具合とエラーの原因となる部分を指摘しておきました。
 
クライアント
  
//省略
*alexi
	repeat
	tcpgetc conper,gas
	if stat=0:break
	await 1
	loop
	repeat conper
	tcpgetc cntg,gas
	size=""			/**********追加**********/
	tcpget size,5,gas
	size=int(size)
	tcpget name.cntg,size+1,gas
	size=""
	mes name.cntg
	loop
 
サーバ
  
#include "pcbnet2.as"
/********* sdimの使い方が間違ってる *****************/
dim soc,10:dim gas,10:sdim user,64,10:sdim pw,64,10:sdim noteexi,64,10
sdim noteexig,64,10:dim arget,10:users=str(users):size=str(size)
tcpmake gbs,5030
//省略
*login
repeat
tcpget size,5,gas.sc
if stat!0:break
await 1
loop
size=int(size)
tcpget user.sc,size+1,gas.sc
size=str(size)
tcpget size,5,gas.sc
size=int(size)
tcpget pw.sc,size+1,gas.sc
mes user.sc
mes pw.sc
size=str(size)
exist ""+user.sc+""+".txt"
if strsize!-1:exi=1
if strsize=-1:exi=0:soc.sc=-1
switch exi
case 1
notesel noteexi.sc
noteload ""+user.sc+""+".txt"
noteget noteexig.sc,0
switch pw.sc
case noteexig.sc
soc.sc=2
conper+
swbreak
default
exi=0
soc.sc=-1
swbreak
swend
swbreak
swend
tcpputc exi,gas.sc
//soc.sc=2	/************* エラーの原因  ***************/
return
*conon
tcpfail gas.sc
switch stat
case 1
soc.sc=0
user.sc=""
pw.sc=""
noteexi.sc=""
//conper-		/************* エラーの原因  ***************/
arget.sc=0
mes "gas."+sc
tcpclose gas.sc
gas.sc=0
swbreak
swend
return
//省略
 
 
 
  |    |   
  
| 
 | 
 
2007/2/13(Tue) 19:02:38|NO.5667 
>長いと読む気がしない・・・ 
そうでした・・・すいません。 
気をつけますね。 
できました! 
ありがとうございます! 
解決しました。 
 
 |   
  
					 |