stefju
03.08.05, 23:30
Hallo,
wer hat bei der Erstellung von eigenen Logikmodulen schon
tiefere Erfahrungen mit den String Funktionen gemacht?
Ich möchte zwei Strings vergleichen.
Die eine geeignete Lib Funktion habe ich auch schon gefunden:
Quelle:
http://docs.python.org/lib/node110.html
<TABLE cellSpacing=0 cellPadding=0><TBODY><TR vAlign=baseline><TD><NOBR><TT class=function id=l2h-838 xml:id="l2h-838">find</TT>(</NOBR></TD><TD><VAR>s, sub</VAR><BIG>[</BIG><VAR>, start</VAR><BIG>[</BIG><VAR>,end</VAR><BIG>]</BIG><VAR></VAR><BIG>]</BIG><VAR></VAR>)</TD></TR></TBODY></TABLE>
<DD>Return the lowest index in <VAR>s</VAR> where the substring <VAR>sub</VAR> is found such that <VAR>sub</VAR> is wholly contained in <CODE><VAR>s</VAR>[<VAR>start</VAR>:<VAR>end</VAR>]</CODE>. Return <CODE>-1</CODE> on failure. Defaults for <VAR>start</VAR> and <VAR>end</VAR> and interpretation of negative values is the same as for slices. </DD>So jetzt ist die Frage wie man dieses einbindet:
Folgender Ausdruck liefert funktioniert bei mir nicht:
5000|"EigeneModule\StringCompare"|0|2|"String (txt)"|"Vergleichs String (txt)"|2|"Ergebnis"|"Ergebnis (sbc)"
# 5001|Anzahl Eingänge|Ausgänge|ZeitSpeicher|Speicher|Berechnu ng bei Start
5001|2|2|0|0|0
#Eingang
5002|1|""|1 # String (txt)
5002|2|""|1 # Vergleichs String (txt)
5004|1|0|0|1|0 #A1 Ausgang; immer Senden bei einer Berechnung
5004|2|0|0|2|0 #A1 Ausgang; Send by change ;
5012|0|"(EI==0) and (EC[1] or EC[2])"|"__import__('string').find(str(EN[1]),str(EN[2]))"|""|1|0|0|0
5012|0|"(EI==0) and (EC[1] or EC[2])"|"__import__('string').find(str(EN[1]),str(EN[2]))"|""|1|0|0|0
Hat jemand dazu eine Lösung?
Gruß Stefan
P.S.
Kann jemand dieses DaCOM Modul erklären:
5000|"DaCom Erweiterungen\StrToFloat"|0|2|"E1 Wert"|"E2 Dezimaltrenner"|3|"A1 Int"|"A2 Float"|"A3 Fehler"|
# bei Start nicht berechnen
5001|2|3|0|0|0
# EN[x]
5002|1|0|1
5002|2|"."|1
# Ausgänge
5004|1|0|0|1|0
5004|2|0|0|1|0
5004|3|0|0|1|0
#################################################
#Zeit senden
5012|"0"|"EN[1].replace('-','',1).isdigit()"|"int(EN[1])"|""|1|0|0|0
5012|"0"|"EN[1].replace('-','',1).replace(EN[2],'',1).isdigit()"|"float(EN[1].replace(EN[2],'.',1))"|""|2|0|0|0
5012|"0"|"EN[1].replace('-','',1).isdigit()"|"0"|""|3|0|0|0
5012|"0"|"not EN[1].replace('-','',1).isdigit()"|"1"|""|3|0|0|0
Was bedeutet diese Zeile:
EN[1].replace('-','',1).isdigit()
wer hat bei der Erstellung von eigenen Logikmodulen schon
tiefere Erfahrungen mit den String Funktionen gemacht?
Ich möchte zwei Strings vergleichen.
Die eine geeignete Lib Funktion habe ich auch schon gefunden:
Quelle:
http://docs.python.org/lib/node110.html
<TABLE cellSpacing=0 cellPadding=0><TBODY><TR vAlign=baseline><TD><NOBR><TT class=function id=l2h-838 xml:id="l2h-838">find</TT>(</NOBR></TD><TD><VAR>s, sub</VAR><BIG>[</BIG><VAR>, start</VAR><BIG>[</BIG><VAR>,end</VAR><BIG>]</BIG><VAR></VAR><BIG>]</BIG><VAR></VAR>)</TD></TR></TBODY></TABLE>
<DD>Return the lowest index in <VAR>s</VAR> where the substring <VAR>sub</VAR> is found such that <VAR>sub</VAR> is wholly contained in <CODE><VAR>s</VAR>[<VAR>start</VAR>:<VAR>end</VAR>]</CODE>. Return <CODE>-1</CODE> on failure. Defaults for <VAR>start</VAR> and <VAR>end</VAR> and interpretation of negative values is the same as for slices. </DD>So jetzt ist die Frage wie man dieses einbindet:
Folgender Ausdruck liefert funktioniert bei mir nicht:
5000|"EigeneModule\StringCompare"|0|2|"String (txt)"|"Vergleichs String (txt)"|2|"Ergebnis"|"Ergebnis (sbc)"
# 5001|Anzahl Eingänge|Ausgänge|ZeitSpeicher|Speicher|Berechnu ng bei Start
5001|2|2|0|0|0
#Eingang
5002|1|""|1 # String (txt)
5002|2|""|1 # Vergleichs String (txt)
5004|1|0|0|1|0 #A1 Ausgang; immer Senden bei einer Berechnung
5004|2|0|0|2|0 #A1 Ausgang; Send by change ;
5012|0|"(EI==0) and (EC[1] or EC[2])"|"__import__('string').find(str(EN[1]),str(EN[2]))"|""|1|0|0|0
5012|0|"(EI==0) and (EC[1] or EC[2])"|"__import__('string').find(str(EN[1]),str(EN[2]))"|""|1|0|0|0
Hat jemand dazu eine Lösung?
Gruß Stefan
P.S.
Kann jemand dieses DaCOM Modul erklären:
5000|"DaCom Erweiterungen\StrToFloat"|0|2|"E1 Wert"|"E2 Dezimaltrenner"|3|"A1 Int"|"A2 Float"|"A3 Fehler"|
# bei Start nicht berechnen
5001|2|3|0|0|0
# EN[x]
5002|1|0|1
5002|2|"."|1
# Ausgänge
5004|1|0|0|1|0
5004|2|0|0|1|0
5004|3|0|0|1|0
#################################################
#Zeit senden
5012|"0"|"EN[1].replace('-','',1).isdigit()"|"int(EN[1])"|""|1|0|0|0
5012|"0"|"EN[1].replace('-','',1).replace(EN[2],'',1).isdigit()"|"float(EN[1].replace(EN[2],'.',1))"|""|2|0|0|0
5012|"0"|"EN[1].replace('-','',1).isdigit()"|"0"|""|3|0|0|0
5012|"0"|"not EN[1].replace('-','',1).isdigit()"|"1"|""|3|0|0|0
Was bedeutet diese Zeile:
EN[1].replace('-','',1).isdigit()