Hello everyone! I am having an issue that I am either stupid and can not see the small error or agk doing something weird. Here is the code I have for the program:
rem
rem AGK Application
rem
setresolutionmode(1)
setvirtualresolution(1024,786)
global net as integer
global net_set as integer
global dim code$[100000]
global title as string
global ip as string
global port as integer
if getfileexists("network.txt")=0
ff = opentowrite("network.txt")
writestring(ff,"127.0.0.1")
writestring(ff, "4444")
closefile(ff)
endif
f = opentoread("network.txt")
ip = readstring(f)
port$ = readstring(f)
closefile(f)
port = val(port$)
net = hostnetwork(ip,"robot", port)
seterrormode(0)
do
print("started version: 1.0.2")
if net > 0
msg = getnetworkmessage(net)
if msg > 0
cmd$ = getnetworkmessagestring(msg)
if cmd$ = "get_app"
x = 0
title = getnetworkmessagestring(msg)
while cmd_recv$ <> "get_CodeEnd"
sync()
cmd_recv$ = getnetworkmessagestring(msg)
code$[x] = cmd_recv$
x = x + 1
endwhile
y = 0
fa = opentowrite(title)
while x <> 0
sync()
writestring(fa,code$[y])
x = x - 1
y = y + 1
endwhile
closefile(fa)
sleep(200)
ffff = opentowrite("command.txt")
writestring(ffff, "copyfileAGK")
writestring(ffff, title)
closefile(ffff)
cmd$ = ""
else
deletenetworkmessage(msg)
fff = opentowrite("command.txt")
writestring(fff, cmd$)
closefile(fff)
msg = createnetworkmessage()
endif
endif
if getfileexists("reply.txt")
ff = opentoread("reply.txt")
send$ = readstring(ff)
closefile(ff)
msg = createnetworkmessage()
addnetworkmessagestring(msg, send$)
sendnetworkmessage(net, 0, msg)
deletenetworkmessage(msg)
deletefile("reply.txt")
endif
endif
sync()
loop
When I send a network message to this application with get_app as the first message (along with more messages) it goes through the code under the:
statement. When I hit the:
fa = opentowrite(title)
while x <> 0
sync()
writestring(fa,code$[y])
x = x - 1
y = y + 1
endwhile
closefile(fa)
it does not produce the file at all! even when the title is populated, and the code array is also populated. I have no clue at this point why this is happening! I do know that a C# program looks at file after it is produced, which would be the closest reason why it does not work. I figure I would ask here for any ideas, thank you in advance!
website: http://worksimpleintelligen.wix.com/parkers-apps
facebook: https://www.facebook.com/ParkersApps
youtube: http://www.youtube.com/user/mrsovr