Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTION_BLOCK FB44
- VAR
- ip_tab:ARRAY[0..3]OF INT; //tablica bajtów do zdekodowania
- ipstring:STRING[16]; //adress ip string
- ipStnigDecode AT ipstring: STRUCT //zdekodowany
- sizemax:BYTE;
- sizeact:BYTE; //rozmiar stringa
- str:ARRAY[1..15]OF CHAR; //tablica znaków
- END_STRUCT;
- indexZnak:INT;// po literach
- indexByte:INT;//kolejne człony
- adressByte:INT; //bajt adresu ip
- END_VAR
- indexByte:=0; adressByte:=0;
- ipstring:='192.168.25.142'; //przykładowy ip
- FOR indexZnak:=1 TO BYTE_TO_INT(ipStnigDecode.sizeact) BY 1 DO
- IF ipStnigDecode.str[indexZnak]='.' THEN
- ip_Tab[indexByte]:=adressByte;
- adressByte:=0;
- indexByte:=indexByte+1;
- ELSE
- adressByte:=adressByte*10+char_TO_INT(ipStnigDecode.str[indexZnak])-48;
- END_IF;
- END_FOR;
- ip_Tab[indexByte]:=adressByte;
- END_FUNCTION_BLOCK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement