Deleting a Variable / Application Error
Hey guys,
I'm looking for a command to close or delete a variable totally. I got the problem that when I'm trying to run my script for the second time this error is occuring:
This is the file in which the error is occuring:
Before starting this script the sample.scv file is created in this file:
I guess the variable is still saved somewhere in hypermesh and thus it can be deleted totally. I'm looking forward to your ideas.
Kind regards
Michael
Find more posts tagged with
Hello thin, thank you for your reply,
the variable is a .csv file which i created with the script ' '. After that i would like to open the file with the script ' --> '. Both scripts starts with a button in the utility menu.
Is it possible that the error related to the memory of Hypermesh? Perhaps the scripts are still running?
I want to close the script ' temp_in_fem.tcl ' with the command 'exit' at the end of the script. Perhaps i should use an other command?
Kind regards
Michael
Hey tinh,
here is the codes you asked for:
set path ''
set name ''
set temp ''
set infor ''
set infor [open C:/Users/Simon/Documents/path.txt r]
#Startinformationen einlesen
while {[gets $infor line]!=-1} {
#Variable zeilenweise auslesen
incr z
#Zeilenzahl
if {$z==1} {set path $line}
if {$z==2} {set temp $line}
if {$z==3} {set name $line}
#Informationen der Zeile 1+2 in Variable schreiben
}
#-------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------
#Programmteil 2: Umrechnung der Knotenspannung
set data ''
set data [open $path/sample.csv r]
#Knotenspannung einlesen
while {[gets $data lines] >=0} {
#Loop für jede Zeile
if {$lines==''} {break}
#Wenn Zeile leer ist, abbruch
incr i
#Loopzähler
if {$i>=1} {
#Ab Zeile 2 in Variable schreiben
set fields [split $lines ',']
lassign $fields field1 field2
#Zeile an Komma trennen, die zwei erstellten Werte in Variablen schreiben
if {![regexp {N/A} $field2]} {
#Wenn in Feld 2 {N/A} steht wird die Zeile nicht in Variable geschrieben
if {$field2>=$temp} {
#Nur wenn Spannung größer als Referenztemperatur, einschreiben
set dif_temp [expr $field2 - $temp]
#Temperatur differenz berechnen
set a 'TEMP'
set b 3
#Parameter die zusätzlich eingeschrieben werden
set formatStr {%0s%12s%8s%8s}
#Zeichenabstand der Variablen definieren (1s = ein Lehrzeichen)
append xxx '[format $formatStr $a $b $field1 [format '%.1f' $dif_temp]]\n'
#write everything in a variable
}
}
}
}
close $data
#-------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------
#Programmteil 3: Suchen der Einfügezeile in der .fem Datei
set fp ''
set fp [open $path/$name r]
set fem_file [read $fp]
close $fp
#öffnen der .fem Datei
set a 0
set b 0
set e 0
#setze Variablen =0
set daten [split $fem_file '\n']
foreach line_pos $daten {
#loop, jede Zeile abfragen
if {![regexp {SPC} $line_pos] || ![regexp {1} $line_pos]} {incr a} else {set b $a}
if {[regexp {SPC} $line_pos] && [regexp {1} $line_pos]} {incr e}
#Logik, für das Finden der individuelle Einfügezeile
}
set num ''
set num [expr $b + $e +1]
#Zeilennummer
#-------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------
#Programmteil 4: Einschreiben in die .fem Datei
set daten ''
set daten [open $path/$name r]
#öffnen der .fem Datei
set y 0
#Setze Variable 0
while {[gets $daten zeile] >=0} {
#Loop einlesen
incr y
#Loopzähler
if {$y<=100} {
append zzz '$zeile\n'
}
#.fem Datei bis Zeile 100 in Variable schreiben
if {$y==$num} {
append zzz '$xxx\n'
}
#Temperaturen in Variable schreiben
if {$y>100} {
#.fem Datei ab Zeile 101 in Variable schreiben
if {![regexp {TEMP} $zeile] || ![regexp {3} $zeile]} {
#wenn bereits Temperaturen in der .fem Datei stehen, diese nicht in die Variable schreiben
append zzz '$zeile\n'
#einschreiben der .fem Zeilen
}
}
}
#-------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------
#Programmteil 5: Outfile erzeugen / Programm schließen
set outfile [open $path/$name w]
puts $outfile $zzz
close $outfile
#outfile erzeugen und Variable einfügen
catch {unset temp outfile}
#zur sicherheit ????????
exit
#Programm schließen
Kind regards,
Simon
What is the variable?
Why do you need to delete it?