Question:
Will There be a 4D release soon to increase the usage of returned values on 4D 
command, so that I can reduce the reliance on system global process variables, 
like “OK"?
    a good 4D command canidate is Receive Packet.
I consider "OK" global variable because it never looses scope, which is what a 
global variable is.

If this is not the Right forum for this question, then the answer to this 
question might be where do I make that request.





Why returned values are a benefit: (optional 
reading)-------------------------------------------------------------

I don’t want to get into a discussion why global variables should not be used. 
There are very legitimate reasons for wanting enhancements of 4D commands to 
return a values

Back to Receive Packet. and why its specifically is a benefit
  Receive Packet($docref;$data;$EOL) for example sets the OK system global 
process variable to 1, unless it reads no data ,then it is sets it to 0
It should be expanded, to return 1 or 0, and for backward compatibility the OK 
could be maintained as is.

Therefor I could write less code lines similar to c#, java, javascript, c++, 
etc. (pseudo example below)
 while(  (line = file.readline()) ==1)
  //do stuff
End while


Currently, because Receive Packet does not return a value, I instead need to 
write code like this in 4D.

Receive Packet($docref;$data;$EOL)  //read the first line
if (ok=1)
repeat 
  //do stuff
  Receive Packet($docref;$data;$EOL) 
until (ok=0)

(OR)

repeat 
Receive Packet($docref;$data;$EOL)  //read, this example not as good because if 
in do stuff changes OK and I don’t program around it, the until will break
if (ok=1)
  //do stuff
end if
until (ok=0)

I realize I could write my own read line method(which I have), but I just 
thought it would be handy if Receive Packet itself could return 1 or 0, in a 
future code release.
It would also be nice if the read line supported CR, CRLF, LF types… I got 
around this by writing my own open file routine, which gets the EOL (this code 
is not shown)

Example of Readline:
While (Readline ($docref;->$read;$EOL)=1)  //Parse the text file referenced , 
returns 1 if not end of File, 0 at end; read is the contents of line; EOL must 
be provided
   //do stuff
End while 

  // Method: readline
C_LONGINT($0)  //returns 1 or 0
C_TIME($1)  //doc reference
C_POINTER($2)  //data can be updated and returned to user
C_TEXT($3)  //EOL
  //variables
C_TEXT($READ)
  //read to EOL character
RECEIVE PACKET($1;$READ;$3)
$2->:=$read
If (Length($read)>0)
$0:=1  //sometimes the last line does not have a EOL, so we still need to 
return 1
Else 
$0:=ok
End if 



thanks,
Aaron
-- 



**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to