SclDestroyHandle
Overview
The purpose of this command is to destroy the SCL handle to a Surpac object, while not destroying the underlying Surpac data.
When you destroy the handle, the memory that the handle was using is released. Otherwise the memory is released only when the macro stops running or when you run SclDestroy (but SclDestroy also deletes the Surpac data from memory).
Syntax
SclDestroyHandle ObjectHandle
Description
SclDestroyHandle works on the following SCL types:
| Object type |
|---|
| Point |
| Segment |
| String |
| Triangle |
| Trisolation |
| Triobject |
| Swa |
| Database |
| Table |
| Column |
| Delete |
| Insert |
| InsertUpdate |
| Query |
| Row |
| Update |
Arguments
| Argument | Description |
|---|---|
| ObjectHandle |
The name of the variable that contains the handle to an object. |
Code Sample
#create a single swa, string and segment
SclCreateSwa SwaHandle "a new layer"
$SwaHandle SclCreateString StringHandle 1
$StringHandle SclCreateSegment SegmentHandle 0
#create some points (a circlein this case)
set pointNum 0
for {set theta 0} {$theta < 361} {incr theta} {
$SegmentHandle SclCreatePoint PointHandle [$SegmentHandle SclCountItems]
$PointHandle SclSetValueByName x [expr {sin($theta*3.1415927/180)}]
$PointHandle SclSetValueByName y [expr {cos($theta*3.1415927/180)}]
$PointHandle SclSetValueByName z 1.0
SclDestroyHandle PointHandle
}
#destroy all the handles we don't need (note swa isn't destroyed as we need it later)
SclDestroyHandle SegmentHandle
SclDestroyHandle StringHandle
#save our data to file
#notice how the string/segment/points still exist in the swa and so are written to file
set today [clock format [clock seconds] -format "%d %b %Y"]
set options "header=test, $today, Test of SclSwaSaveStringFile, mystyles.ssi|axis=0, 0.0, 0.0, 0.0, 100.0, 100.0, \
0.0|binary=off"
SclGetActiveViewport ViewportHandle
$ViewportHandle SclSetActiveLayer SwaHandle
if {[catch {$SwaHandle SclSwaSaveStringFile demo1.str "$options"}] != 0} {
# this is how we trap for errors
puts "Error saving active layer to demo1.str"
} else {
# save was successful
puts "active layer saved to demo1.str"
}
#finally, destroy our swa (and its contents)
SclDestroy SwaHandle
|