Posted: 16th Jun 2007 8:35
Hey Guys,
Im working on a program that lets save/load things that you draw on the screen. It saves the pictures as an array with info on the pixel value. Im hoping to make it act like a instant messanger but there is no way i can think of to send an array.
thx in advance
Posted: 16th Jun 2007 9:39
You should send them out piecemeal, and receive them the same way. The concept of the array is not what you are exposing; and it is a weak metaphor - quite limiting. Strings are the same way. They are convenient inside the program, but a bit laborious to ferry in and out.

At some point, it will become an increasingly good idea to reduce it to what it is: an exchange of binary information with no regard to its actual use, just to get it transferred without any ill side-effects. It is really as simple as dealing with each field as a sequence of bytes.

If you want to post up a snippet of what you want to do, I will write you an input and output to a file. That is how you would do it anyway. Also, I could show you how to insert it and extract it to/from a flat buffer, which is pretty generic, and useful.
Posted: 16th Jun 2007 18:41
Heres the code

+ Code Snippet
set window size 640,480
new:
do
     ox=x
     oy=y
     x=mousex()
     y=mousey()
     if oy>50 and y>50 then if mouseclick()=1 then line ox,oy,x,y
     rem if keystate(2)=1
     if keystate(3)=1 then goto load
     if keystate(4)=1 then goto save
     if keystate(5)=1 then cls
     rem if keystate(6)=1
     line 0,50,640,50
     center text 160,20,"1=RECIEVE"
     center text 240,20,"2=LOAD"
     center text 320,20,"3=SAVE"
     center text 400,20,"4=CLEAR"
     center text 480,20,"5=SEND"
loop

save:
     print "SAVE"
     input pic$
     dim pic(640,480)
     for x=0 to 640
          for y=50 to 480
              pic(x,y)=point(x,y)
          next y
     next x
     save array pic$,pic(0)
     cls
goto new

load:
     print "LOAD"
     input pic$
     load array pic$,pic(0)
     cls
     for x=0 to 640
          for y=50 to 480
              dot x,y,pic(x,y)
          next y
     next x
goto new



Do you mean something like this?

+ Code Snippet
send:
     for x=0 to 640
          for y=50 to 480
               pic(x,y)=point(x,y)
               send net message integer 0,pic(x,y)
          next y
     next x
goto picmsg

recieve:
     if net message exists()=1
          get net message
          for x=0 to 640
               for y=50 to f80
                    pic(x,y)=net message integer
               next y
          next x
     endif
goto picmsg