|
看看一个例子。
For example, lets say you have to capture the PID from the following receive buffer (This is
an example from LR function reference):
"\r"
"\x0 blah blah blah "
"\r\n blah blah blah "
"PID TT STAT TIME COMMAND\r\n PID 28469 q2"
" S 0:01 -tcsh (tcsh)\r\n"
……
In a typical web script, you would use a web_create_html_param and use “PID “ and “ q2” as
the boundaries to capture the data.
In a Winsock script, you would use lrs_save_param that saves data from a static or received
buffer to a parameter. See the example below:
lrs_receive("socket2", "buf47", LrsLastArg);
lrs_save_param("socket2", NULL, "param1", 67, 5);
Unlike web_create_html_param, lrs_save_param goes after the request is made. In
this example, the first statement is receiving buf47. The following are the arguments
used in the lrs_save_param statement:
socket2: Capture from a buffer on socket2
NULL: NULL indicates that the parameter should be captured from the last received buffer. In
this case it is buf47. If you were to capture from any other buffer, you will have to specify the
buffer number.
param1: Name of the LR parameter in which to staore the captured value
67: Offset – explained below.
5: length of the to be captured
Offset: This is the number of bytes from the beginning of the buffer to start capturing. In the
above example, the PID starts after 67 bytes from the beginning of buf47. How do you
determine this?
Highlight the whole buffer in data.ws that contains the parameter to be captured and hit F7.
This will bring up a window as shown below:
In the left column, you will see the offset that corresponds to that line. In the middle 4
columns, you see the EBCDIC translation of the buffer. And in the right column, you have the
actual buffer itself. So if you look at the fifth line in the actual buffer, that is where you PID
lies. But we want to start capturing after the third location in that line. The offset for that
entire line is 64, and the offset for the PID within that line is 3, which makes the offset 67.
(Now does that explain why I had to add all those blah blah blahs in the buffer to make it
match my example? J) |
|