Автор: tametung
Дата сообщения: 08.04.2013 21:57
suz191
Вот примерно так:
Код:
/* REXX */
NUMERIC DIGITS 18
call ZocTimeout 3
DIR_PART="C:\_DUMPS"
is_CONNECT:
i=0
j=0
BEGIN:
if i=0 then do
j=j+1
if j=3 then do
ERROR:
say "COMMUNICATION PROBLEM.SCRIPT STOP"
exit
end
abst=Z_IN("^M",,0.4)
i=pos(">",abst,1)
call ZocDelay 0.4
signal BEGIN
end
LEVEL=substr(abst,i,1)
abst=Z_IN("^M")
MAIN: LOCATION=""
ADDR=GET("ADDRESS ?",copies("0",8),08)
abst=Z_IN("AP "||ADDR||"^M")
if pos("Ptr",abst,1)=0 then signal ERROR
COUNT=GET("BYTES ?","8"||copies("0",5),06)
OUT_FILE=F_CREATE(DIR_PART,"F3_FLASH_"||ADDR||"_"||COUNT||".BIN") ;T1=time(S)
abst=Z_IN("TE^M")
if pos("off",abst,1)=0 then abst=Z_IN("TE^M")
call GET_BYTE "RD^M"
do j=1 to x2d(COUNT)-1
call GET_BYTE "^M",x2d(COUNT)-1
end
call stream OUT_FILE,"C","CLOSE"
say "SAVED TO:"
say OUT_FILE||" in "||time(S)-t1||" sec"
signal MAIN
Z_IN:
parse arg V1,V2,V3
if V2="" then V2=LEVEL
call ZocReceiveBuf 7680
if V1\="" then call ZocSend V1
if V3\="" then call ZocDelay V3
else call ZocWait V2
RETURN ZocReceiveBuf(0)
GET:
PARSE ARG MSG,DEFAULT,TYPE,GO2
IF GO2="" THEN GO2=L0
L0: TMP=WORD(ZOCASK(MSG,DEFAULT),1)
IF TMP="" | TMP="##CANCEL##" THEN CALL CHK_NO GO2
IF TYPE="" THEN RETURN TMP
IF DATATYPE(TMP,X)=0 THEN DO
say ""
SAY "PARAM ["||TMP||"] NOT HEX.RETRY"
SIGNAL L0
END
RETURN TRANSLATE(RIGHT(TMP,TYPE,"0"))
CHK_NO:
PARSE ARG V1,V2
V2=LOCATION
TMP= ZOCMSGBOX(V2||" CONTINUE ?",2)
IF TMP=##YES## THEN SIGNAL VALUE V1
IF V2<>"" THEN SIGNAL MAIN
SAY "BYE!"
EXIT
F_CREATE:
PARSE ARG V1,V2
IF STREAM(V1,"C","QUERY EXISTS")="" THEN DO
CALL ZOCSHELL MD V1,1
END
TMP=V1||"\"||V2
IF STREAM(TMP,"C","QUERY EXISTS")<>"" THEN DO
CALL ZOCSHELL DEL TMP,1
END
CALL STREAM TMP,"C","OPEN WRITE"
RETURN TMP
GET_BYTE:
parse arg V1,V2
abst=Z_IN(V1)
i=pos("x",abst,1)
if i=0 then do
say "UNKNOWN FORMAT.SCRIPT STOP"
exit
end
BYTE=substr(abst,i+1,2)
CALL CHAROUT OUT_FILE,x2c(BYTE)
RETURN