Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SCL 0.92 KB | None | 0 0
  1. FUNCTION_BLOCK FB44
  2. VAR
  3.     ip_tab:ARRAY[0..3]OF INT; //tablica bajtów do zdekodowania
  4.     ipstring:STRING[16]; //adress ip string
  5.     ipStnigDecode AT ipstring: STRUCT //zdekodowany
  6.         sizemax:BYTE;
  7.         sizeact:BYTE;   //rozmiar stringa
  8.         str:ARRAY[1..15]OF CHAR; //tablica znaków
  9.     END_STRUCT;
  10.     indexZnak:INT;// po literach
  11.     indexByte:INT;//kolejne człony
  12.     adressByte:INT; //bajt adresu ip
  13. END_VAR
  14.     indexByte:=0; adressByte:=0;
  15.     ipstring:='192.168.25.142'; //przykładowy ip
  16.     FOR indexZnak:=1 TO BYTE_TO_INT(ipStnigDecode.sizeact) BY 1 DO
  17.         IF ipStnigDecode.str[indexZnak]='.' THEN
  18.             ip_Tab[indexByte]:=adressByte;
  19.             adressByte:=0;
  20.             indexByte:=indexByte+1;  
  21.         ELSE
  22.             adressByte:=adressByte*10+char_TO_INT(ipStnigDecode.str[indexZnak])-48;
  23.         END_IF;
  24.     END_FOR;
  25.     ip_Tab[indexByte]:=adressByte;
  26. END_FUNCTION_BLOCK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement