Hey,
ich erzeuge mit der Fileio nach Benutzereingabe "Macroprogramme" für eine CNC-Anlage und lege diese als File auf der CF ab. Siehe unten (Auszug aus dem QC).
Schreib doch einfach anstatt strcpy(buffer,";");
und gut ist! Ich Sende auch Daten über TCP/IP mit Delemiter ";". String zusammenbasteln und weg damit.
strcpy( buffer, "X" );
ftoa( makro1.length+makro1.start_x, (UDINT) tempstring );
strcat( buffer, tempstring );
strcat( buffer, CRLF "G02 Y" );
ftoa( makro1.act_y, (UDINT) tempstring );
strcat( buffer, tempstring );
strcat( buffer, " I0 J-" );
ftoa( makro1.distance / 2, (UDINT) tempstring );
strcat( buffer, tempstring );
strcat( buffer, CRLF "X" );
ftoa( makro1.start_x, (UDINT) tempstring );
strcat( buffer, tempstring );
strcat( buffer, CRLF "G03 Y" );
ftoa( makro1.act_y - makro1.distance, (UDINT) tempstring );
strcat( buffer, tempstring );
strcat( buffer, " I0 J-" );
ftoa( makro1.distance / 2, (UDINT) tempstring );
strcat( buffer, tempstring );
strcat( buffer, CRLF );
Hier noch das TCP/IP Beispiel zum String zusammensetzen:
case '1':
strcpy( tempstring, ";" );
/* Art */
ftoa( ART, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Jahr */
ftoa( JAHR, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Monat */
ftoa( MONAT, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Tag */
ftoa( TAG, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Stunde */
ftoa( STUNDE, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Minute */
ftoa( MINUTE, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Sekunde */
ftoa( SEKUNDE, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Anlage */
ftoa( ANLAGE, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Status */
ftoa( STATUS, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Personalnummer */
strcat( tempstring, PERSONAL );
strcat( tempstring, ";" );
/* Programm */
strcat( tempstring, PROGRAMM );
strcat( tempstring, ";" );
/* Geschwindigkeit */
ftoa( SPEED, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Soll_Temperatur */
ftoa( SOLLTEMP, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Ist_Temperatur */
ftoa( ISTTEMP, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Wellenfaktor */
ftoa( WELLE, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Bremsfaktor vor */
ftoa( BREMSVOR, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Bremsfaktor nach*/
ftoa( BREMSNACH, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Niederhalter Zustand */
ftoa( NIEDERSTAT, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Niederhalter + */
ftoa( NIEDERPLUS, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Niederhalter - */
ftoa( NIEDERMINUS, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Restdraht */
ftoa( RESTDRAHT, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Meld_Notaus */
ftoa( MELD1, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Meld_Phase */
ftoa( MELD2, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
/* Meld_Drahtbruch */
ftoa( MELD3, (UDINT) tempstring + strlen(tempstring));
strcat( tempstring, ";" );
client.send.pData = (UDINT) tempstring;
client.send.datalen = strlen( (char*) tempstring );
client.send.enable = 1;
Zum Thema in Float in String oder CHR$ umwandeln habe ich mir folgendermassen geholfen:
(Lese über die Serielle Schnittstelle RFID-Chip's vom Personal aus (QS) Leseeinheit mit Chip's ca. 60 Euronen)
Die Wandlung im AS/Basic lässt eben zu Wünschen übrig!
strcpy(adr(PERSONAL),"")
loop Index = 2 to 11 do
if read_data[Index]=48 then
strcpy(ADR(PERS),"0")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=49 then
strcpy(ADR(PERS),"1")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=50 then
strcpy(ADR(PERS),"2")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=51 then
strcpy(ADR(PERS),"3")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=52 then
strcpy(ADR(PERS),"4")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=53 then
strcpy(ADR(PERS),"5")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=54 then
strcpy(ADR(PERS),"6")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=55 then
strcpy(ADR(PERS),"7")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=56 then
strcpy(ADR(PERS),"8")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=57 then
strcpy(ADR(PERS),"9")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=65 then
strcpy(ADR(PERS),"A")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=66 then
strcpy(ADR(PERS),"B")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=67 then
strcpy(ADR(PERS),"C")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=68 then
strcpy(ADR(PERS),"D")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=69 then
strcpy(ADR(PERS),"E")
strcat(adr(PERSONAL), adr(PERS))
endif
if read_data[Index]=70 then
strcpy(ADR(PERS),"F")
strcat(adr(PERSONAL), adr(PERS))
endif
endloop
Vielleicht hilf es Dir ja.
Sende Dir gerne mehr QC!
Gruss Skyracer