ISaGRAF. Version 3.4

         

FM_READ


Àðãóìåíòû:

ID                         INT                 íîìåð ôàéëà: âîçâðàùåííûé ôóíêöèåé F_ROPEN

Q                          MSG              ñîîáùåíèå ñ÷èòàííîå èç ôàéëà

Îïèñàíèå:

×èòàåò ñòðîêîâûå ïåðåìåííûå èç äâîè÷íîãî ôàéëà. Äîëæíà èñïîëüçîâàòüñÿ ñ F_ROPEN è F_CLOSE.  Ýòà ôóíêöèÿ îñóùåñòâëÿåò ïîñëåäîâàòåëüíûé äîñòóï ê ôàéëó, íà÷èíàÿ ñ ïðåäûäóùåé ïîçèöèè. Ïåðâûé âûçîâ ïîñëå F_ROPEN ÷èòàåò ïåðâóþ ñòðîêó ôàéëà, êàæäûé âûçîâ ñäâèãàåò óêàçàòåëü ÷òåíèÿ. Ñòðîêà çàêàí÷èâàåòñÿ íóëåì (0), ñèìâîëîì êîíöà ñòðîêè (‘\n’) èëè âîçâðàòîì (‘\r’);

Äëÿ ïðîâåðêè äîñòèãíóò ëè êîíåö ôàéëà èñïîëüçóéòå F_EOF.  Ýòà ôóíêöèÿ íå âêëþ÷åíà â ñèìóëÿòîð ISaGRAF.

(*FBD ïðîãðàììà, èñïîëüçóþùàÿ áëîêè óïðàâëåíèÿ ôàéëîì*)

(* ST Ýêâèâàëåíò: *)

file_id := F_ROPEN('voltramp.bin');

status1 := FM_READ(file_id);

status2 := FM_READ(file_id);

IF (F_EOF(file_id)) THEN

                ERROR := ERR_FILE;

                unused_eof_mes := FM_READ(file_id);

END_IF;

ok := F_CLOSE(file_id);

(* IL Ýêâèâàëåíò: *)

                         LD              'voltramp.bin'

                         F_ROPEN

                         ST              file_id

                         FM_READ                      (* ÷èòàòü status1 *)

                         ST              status1

                         LD              file_id

                         FM_READ                      (* ÷èòàòü status2 *)

                         ST              status2

                         LD              file_id

                         F_EOF

                         JMPNC        CLOSE_FILE              (* åñëè êîíåö ôàéëà, òî íå äåëàòü ïðûæîê *)

                         LD              ERR_FILE

                         ST              ERROR

                         LD              file_id

                         FM_READ                      (* ÷èòàòü unused_eof_mes *)

                         ST              unused_eof_mes

CLOSE_FILE     LD              file_id

                         F_CLOSE

                         ST              ok



Ñîäåðæàíèå ðàçäåëà