I am trying to write a TCP client in Karel to talk to a simple python server. I went through the manual and configured a client on $HOST_CFG[1]. I typed the example client from the manual into Notepad++(I couldn't copy paste)
Code
PROGRAM loopcl
%STACKSIZE = 4000
%NOLOCKGROUP
%NOPAUSE=ERROR+COMMAND+TPENABLE
%ENVIRONMENT uif
%ENVIRONMENT sysdef
%ENVIRONMENT kclop
%ENVIRONMENT bynam
%ENVIRONMENT fdev
%ENVIRONMENT flbt
%INCLUDE klevccdf
%INCLUDE klevkeys
%INCLUDE klevkmsk
VAR
file_var : FILE
tmp_int : INTEGER
tmp_str : STRING[128]
status : INTEGER
entry : INTEGER
loop1 : BOOLEAN
BEGIN
SET_FILE_ATR(file_var, ATR_IA)
SET_VAR(entry, '*SYSTEM*'. '$HOST_CFG[1].$SERVER_PORT',80000,status)
-- Connect the tag
WRITE('Connecting...',CR)
MSG_CONNECT('C1:',status)
WRITE(' Connect status = ',status,CR)
loop1 = TRUE
IF status = 0 THEN
WHILE loop1 = TRUE DO
WRITE('Opening file...',CR)
OPEN FILE file_var('rw','C1:')
status = IO_STATUS(file_var)
IF status = 0 THEN
FOR tmp_int = 1 TO 100 DO
tmp_str = '0123456789012345'
WRITE file_var(tmp_str::10)
WRITE('Wrote 126 bytes',CR)
IF status <> 0 THEN
WRITE('Loop test fails',CR)
loop1 = FALSE
tmp_int = 100
ELSE
WRITE('Read 126 bytes',CR)
READ file_var(tmp_str::10)
status = IO_STATUS(file_var)
WRITE('Read status ', status,CR)
ENDIF
ENDFOR
WRITE('Closed file',CR)
CLOSE FILE file_var
ELSE
WRITE('Error opening file',CR)
loop1 = FALSE
ENDIF
ENDWHILE
WRITE('Disconnecting...',CR)
MSG_DISCO('C1:',status)
WRITE('Done.',CR)
ENDIF
END loopcl
Display More
We have HandlingPro evaluation version. I was able to load and compile simple programs. I tried to load the Karel_Client.ls program, and got error messages (see attached). I am not sure what they mean. Clicking on them does not help.
Could someone point me in a direction on how to debug?