DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract bits from a 32-Bit number and write them to new created channels

Hi,
 
i'm trying to extract bit 8, 20 and 21 from a 32-bit number, e.g. 1069404151.I've wrote a script but i always become an runtime error message.My script is:
 
j=1
do
   number=CHD(j,74)
   result1=GetB(number,8)
   CHD(j, MyChannel.ChannelName)=result1
   result2=GetB(Zahl,20)
   CHD(j, MyChannel1.ChannelName)=result2
   result3=GetB(number,21)
   CHD(j, MyChannel2.ChannelName)=result3
   j=j+1
loop until(j<1000) 
 
If i change the condition to loop until(j<10), there's no problem.But as soon as i changed it to j<1000, it didn't match anymore.What could be the problem?
 
Thanks a lot for your help.
 
Regards
Patrick Etoumann
0 Kudos
Message 1 of 6
(4,270 Views)
Hello Patrick!

I tried to run your script and found two faults:

- result2=GetB(Zahl,20) should be result2=GetB(number,20)
- loop until(j<1000) should be loop while(j<1000) (I think a for loop is in this case a little bit better)

I have changed this and the script runs without a fault.

If you still get a fault please copy the error message in to your description.

Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 6
(4,265 Views)

Hi Thomas,

Thanks for your answer.I made the changes as you wrote but i still become the same error message.This is a copy from my logdata:

"Fehler in <Ventildi...it02.VBS> (Zeile: 45, Spalte: 4):  Unbekannter Laufzeitfehler"

In my channels i have the requested bits for the first ten numbers, and after writing the tenth row the error message appears.

Patrick

Patrick Etoumann
0 Kudos
Message 3 of 6
(4,261 Views)

Hi Matthias,

Sorry, i called you Thomas, i don't know why??   

Xcuse-me for this mistake.

Patrick

Patrick Etoumann
0 Kudos
Message 4 of 6
(4,261 Views)
Hallo Patrick!

Dir sei verziehen, zum Ausgleich mach ich aber mal in Deutsch weiter.

Ich konnte deinen Fehler reproduzieren nachdem ich meine Grundeinstellung für den Datenbereich geändert habe und dort als Kanalllänge 10 eingetragen habe. DIAdem kann dann nur bis zu diesem Wert automatisch neue Werte in einem Kanal aufnehmen und bricht dann (bei 9.1) nach dem 10. Wert mit der nichtssagenden Fehlermeldung ab.

Lösung des Problems liegt darin die Ergebniskanäle in der notwendigen Länge mit dem Befehl ChnAlloc anzulegen oder ChnReAlloc anzupassen. Also so: Call ChnAlloc(MyChannel.ChannelName,1000). Das ist dann für alle 3 Kanäle notwendig.

Ich hoffe das hilft

Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 5 of 6
(4,254 Views)

Hi Matthias,

Danke für Deine Hilfe.Es hat super funktioniert!!

Schönes WE

Patrick

Patrick Etoumann
0 Kudos
Message 6 of 6
(4,251 Views)