Quantcast
Channel: SPS-Forum - Automatisierung und Elektrotechnik
Viewing all articles
Browse latest Browse all 46421

TIA For Schleife einbinden

$
0
0
Hallo zusammen, ich würde gerne den unteren Code einkürzen und mit einer Schleife hoch zählen wollen, bisher sind meine Versuche gescheitert:confused:

#Offset_Input = Eingangsbyte, Parameter wird beim Aufruf an parametriert. (96)

Poke => byteOffset wird ebenfalls von außen an parametriert und mit einem Byte hochgezählt

******************************************************************************** ********************
So sollte es ungefähr aussehen

FOR #counter := #Offset_Input TO 125 DO

#Pufferwert := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter);

//Offset wird ausserhalb anparametriert
//
POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 1,
value := #Pufferwert);

END_FOR;

******************************************************************************** *********************

So ist es momentan..



#counter := #Offset_Input;




#Puffer[1] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter);


POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset :=#Offset,
value := #Puffer[1]);

#Puffer[2] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter +1);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 1,
value := #Puffer[2]);

#Puffer[3] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 2);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 2,
value := #Puffer[3]);

#Puffer[4] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 3);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 3,
value := #Puffer[4]);

#Puffer[5] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 4);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 4,
value := #Puffer[5]);

#Puffer[6] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 5);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 5, //+ #counter,
value := #Puffer[6]);

#Puffer[7] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 6);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 6, //+ #counter,
value := #Puffer[7]);

#Puffer[8] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 7);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 7, //+ #counter,
value := #Puffer[8]);

#Puffer[9] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 8);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 8, //+ #counter,
value := #Puffer[9]);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 7, //+ #counter,
value := #Puffer[8]);

#Puffer[10] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 9);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 9, //+ #counter,
value := #Puffer[10]);

#Puffer[11] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 10);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 10, //+ #counter,
value := #Puffer[11]);

#Puffer[12] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 11);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 11, //+ #counter,
value := #Puffer[12]);

#Puffer[13] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 12);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 12, //+ #counter,
value := #Puffer[13]);

#Puffer[14] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 13);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 13, //+ #counter,
value := #Puffer[14]);

#Puffer[15] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 14);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 14, //+ #counter,
value := #Puffer[15]);

#Puffer[16] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 15);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 15, //+ #counter,
value := #Puffer[16]);


#Puffer[17] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 16);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 16, //+ #counter,
value := #Puffer[17]);

#Puffer[18] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 17);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 17, //+ #counter,
value := #Puffer[18]);

#Puffer[19] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 18);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 18, //+ #counter,
value := #Puffer[19]);

#Puffer[20] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 19);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 19, //+ #counter,
value := #Puffer[20]);

#Puffer[21] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 20);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 20, //+ #counter,
value := #Puffer[21]);

#Puffer[22] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 21);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 21, //+ #counter,
value := #Puffer[22]);

#Puffer[23] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 22);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 22, //+ #counter,
value := #Puffer[23]);

#Puffer[25] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 24);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 24, //+ #counter,
value := #Puffer[25]);

#Puffer[26] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 25);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 25, //+ #counter,
value := #Puffer[26]);


#Puffer[27] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 26);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 26, //+ #counter,
value := #Puffer[27]);

#Puffer[28] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 27);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 27, //+ #counter,
value := #Puffer[28]);

#Puffer[29] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 28);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 28, //+ #counter,
value := #Puffer[29]);

#Puffer[30] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 29);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 29, //+ #counter,
value := #Puffer[30]);


#Puffer[31] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 30);

POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 30, //+ #counter,
value := #Puffer[31]);



#Puffer[32] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #counter + 31);


POKE(area := 16#84,
dbNumber := #DBNR,
byteOffset := #Offset + 31, //+ #counter,
value := #Puffer[32]);


Danke für eure Vorschläge

Viewing all articles
Browse latest Browse all 46421


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>