DataRead And Function molding.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by pbdep.


Hello PB Team,

ReceiveNetworkData returns the 'Result' of receieve data.

Why does ReadData not do this?

I would expect every read action into a buffer would return
the result of read data, this is much easier then checking
with an extra commandrows howmuch data there was read.

I would suggest to change ReadData into (with extra Result return) ->
***
Result = ReadData(*memory,LengthToRead)

The 'Result' returns the number of byte effectively read. If 'Result' is equal to LengthToRead, then more data is available to be read.
***

This will make PB more consequent and easier too on Read actions :wink:
Wheater its a File or a Socket Read actions into Memory would be made easier when there is a result length returned in this case.


PS: If you would like to make Life more easier :wink: Then you could
also make 1 Read function, that is AND able to read from sockets
AND able to read from files, because the #File will pointout to
the constant, the compiler will know whether its a #PORT or a #FILE.

that would make something like this:

For a FILE :

CID = OpenFile(0,"hello.exe")
ReadData(CID,*buffer,length)

For a Socket (PORT) :

CID = OpenNetWorkConnection("127.0.0.1",port)
ReadData(CID,*buffer,length)



Continueing on this issue you could also extent for
ServerSide sockets like :


CID = NetWorkClientID()
WriteData(cid,*buffer,length)


Anyway..I think using the above you will surely make PB more
flexible and I had a look into the standard functions which shows
me that it IS possible to adjust. Less Functions results into
more Flexible Functions.

I hope you give it a thought, for now the First suggestion
with the result would be a nice enhancement. The Seconds issue
would ofcause meen a new PB release.

Regards,
Norman.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

ReadData() returns the amount of data read, just try it, perhaps it should be mentioned in the manual though?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by pbdep.
Originally posted by Pupil

ReadData() returns the amount of data read, just try it, perhaps it should be mentioned in the manual though?
Hi Pupil,

That was my reason for the posting, I cant (PB cant) debug/(Realtime)under LINUX so im relying 100% on the documents. If the Docs are in more detailed describing the "Result" (which it does not) then It would be easier (whitout try & error) get the meaning of the function.

I hope PB Team puts the docs under the lamp soon..


anyway..thanx for the reply :)
Regards,
Norman.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

OK, so you work with the Linux version, i'm not 100% sure that the command returns the same info as the windows version does, cause i haven't tried PB on Linux...But hopefully it's the same on all OS versions of PB..
Post Reply