Attribute VB_Name = "Modeditor"
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOREDRAW = &H8
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Public EditorX&        'Coordinata X del form di editor
Public EditorY&        'Coordinata Y del form di editor
Public LaserVersion$ 'versione laser
Public FileDescription$ 'descrizione file corrente
Public LasReferenceX$ 'Reference point X corrente (laser)
Public LasReferenceY$ 'Reference point Y corrente (laser)
Public LasReferenceX1$ 'Reference point X corrente (laser tavola a)
Public LasReferenceY1$ 'Reference point Y corrente (laser tavola b)
Public TabReferenceZ$ 'Reference point asse Z (tavola)
Public TabReferenceW$ 'Reference point asse W (tavola)
Public TabStepZ$ 'numero millimetri step Z
Public TabStepW$ 'numero millimetri step W
Public NumStepZ$ 'numero  step lungo Z
Public NumStepW$ 'numero step lungo W
Public TrimExe$ 'ordine esecuzione tagli
Public TLasReferenceX$ 'Reference point X corrente (laser)
Public TLasReferenceY$ 'Reference point Y corrente (laser)
Public TLasReferenceX1$ 'Reference point X corrente (tavola B)
Public TLasReferenceY1$ 'Reference point Y corrente (tavola B)
Public TTabReferenceZ$ 'Reference point asse Z (tavola)
Public TTabReferenceW$ 'Reference point asse W (tavola)
Public TTabStepZ$ 'numero millimetri step Z (temporanea)
Public TTabStepW$ 'numero millimetri step W (temporanea)
Public TNumStepZ$ 'numero  step lungo Z (temporanea)
Public TNumStepW$ 'numero step lungo W (temporanea)
Public TTrimExe$ 'ordine esecuzione tagli (Temporaneo)
Public usepsi$    'se "1" utilizza PSI
Public Uusepsi$    'se "1" utilizza PSI
Public Hasdone%     'flag di attesa
Public execution$   'stringa che contiene l'ordine di esecuzione dei tagli
Public filoffset& 'offset file dati inizio record

'tipo di record generico
'con accesso dati tipo sequenziale
Public Type genrecord
    genfield As String * 2048
End Type

'record dati
'alla lunghezza reale del campo
'viene aggiunta la lunghezza del terminatore (2)
Public Type trimrecord
    'start x
    startx As String * 13
    'start y
    starty As String * 13
    'stop x
    stopx As String * 13
    'stop y
    stopy As String * 13
    'valore ohmico
    ohmvalue As String * 11
    'velocita' taglio
    speed As String * 7
    'corrente
    current As String * 7
    'freq. laser
    freq As String * 7
    'scanner h
    scanh As String * 5
    'scanner l
    scanl As String * 5
    'scanner g
    scang As String * 5
    'slope
    slope As String * 3
    'tolleranza accettazione pretest
    tolaccept As String * 5
    'tolleranza taglio finale
    tolcut As String * 5
    'tipo di taglio
    cutType As String * 4
    'direzione inizio taglio
    cutDir As String * 3
    'percentuale primo stop
    cut1St As String * 5
    'percentuale prestop
    cutPre As String * 5
    'valore in volt scatto funzionale
    voltvalue As String * 11
    'mark condition
    mark As String * 3
    'taglio funzionale
    func As String * 3
    'step taglio serp
    serpstep As String * 6
    'identificatore di res.
    reslabel As String * 12
    'se 1 usa visione
    vision As String * 3
    'sviluppi futuri
    sparedata As String * 1881
End Type

Public myrecord As trimrecord
Public myrecord1 As trimrecord
Public myrecord2 As trimrecord
Global TrimMatrix() As trimrecord
Global TrimMatrix1() As trimrecord
Global psistring$ 'contiene il testo del file PSI
Function cleanval$(theitem$)
'legge il campo corrente e lo pulisce dal terminatore e
'dagli spazi aggiuntivi
    cleanval$ = Trim$(Left$(theitem$, Len(theitem$) - Len(term$)))
End Function
Sub addval(tfield$, inpt$)
    'aggiusta in lunghezza il campo del record
    tfield$ = Space$(Len(tfield$) - Len(inpt$) - Len(term$)) + inpt$ + term$
End Sub
Sub getrecord(fn%, rn%)
rrnn& = rn%
thepos& = ((rrnn& - 1) * Len(myrecord)) + filoffset&
Seek fn%, thepos&
ll& = Len(myrecord)
thestring$ = Input$(ll&, fn%)
Call CopyMemory(myrecord, ByVal thestring$, ll&)
End Sub
Sub Putrecord(fn%, rn%)
rrnn& = rn%
thepos& = ((rrnn& - 1) * Len(myrecord)) + filoffset&
Seek #fn%, thepos&
thestring$ = Space$(Len(myrecord))
ll& = Len(myrecord)
Call CopyMemory(ByVal thestring$, myrecord, ll&)
Put #fn%, , thestring$
End Sub

Sub fileopener(fn$)
psistring$ = ""
lastfile$ = fn$
FrmEuro.Caption = fn$
thefn$ = thepath1$ + fn$ + ".dat"
thefn1$ = thepath1$ + fn$ + ".txt"
ex$ = ""
ex$ = Dir$(thefn1$)
If ex$ <> "" Then
    un% = FreeFile
    Open thefn1$ For Input As #un%
    ll& = LOF(un%)
    psistring$ = Input$(ll&, un%)
    Close #un%
End If
ex$ = ""
ex$ = Dir$(thefn$)
If ex$ = "" Then lastfile$ = "\": Exit Sub
un% = FreeFile
Open thefn$ For Input As #un%
Line Input #un%, LaserVersion$
Line Input #un%, FileDescription$
Line Input #un%, LasReferenceX$
Line Input #un%, LasReferenceY$
Line Input #un%, LasReferenceX1$
Line Input #un%, LasReferenceY1$
Line Input #un%, TabReferenceZ$
Line Input #un%, TabReferenceW$
Line Input #un%, TabStepZ$
Line Input #un%, TabStepW$
Line Input #un%, NumStepZ$
Line Input #un%, NumStepW$
Line Input #un%, TrimExe$
Line Input #un%, usepsi$
If Trim$(LasReferenceX$) = "" Then LasReferenceX$ = Trim$(Str(RefX&))
If Trim$(LasReferenceY$) = "" Then LasReferenceY$ = Trim$(Str(RefY&))
If Trim$(LasReferenceX1$) = "" Then LasReferenceX1$ = Trim$(Str(RefX1&))
If Trim$(LasReferenceY1$) = "" Then LasReferenceY1$ = Trim$(Str(RefY1&))
If Trim$(TabReferenceZ$) = "" Then TabReferenceZ$ = Trim$(Str(RefZ&))
If Trim$(TabReferenceW$) = "" Then TabReferenceW$ = Trim$(Str(RefW&))
TLasReferenceX$ = LasReferenceX$
TLasReferenceY$ = LasReferenceY$
TLasReferenceX1$ = LasReferenceX1$
TLasReferenceY1$ = LasReferenceY1$
TTabReferenceZ$ = TabReferenceZ$
TTabReferenceW$ = TabReferenceW$
TTabStepZ$ = TabStepZ$
TTabStepW$ = TabStepW$
TNumStepZ$ = NumStepZ$
TNumStepW$ = NumStepW$
TTrimExe$ = TrimExe$
Uusepsi$ = usepsi$
filoffset& = Seek(un%)
Ntrim& = (LOF(un%) - filoffset&) / Len(myrecord)
Numtrim% = Ntrim&
Close #un%
Open thefn$ For Binary As #un%
Erase TrimMatrix
Erase TrimMatrix1
ReDim TrimMatrix(1 To Numtrim%) As trimrecord
ReDim TrimMatrix1(1 To Numtrim%) As trimrecord
For i% = 1 To Numtrim%
    Call getrecord(un%, i%)
    TrimMatrix(i%) = myrecord
    TrimMatrix1(i%) = myrecord
Next i%
Close #un%
FrmEuro.Enabled = False
If justloaded% = 0 Then
        Call gotoposxyzw(LasReferenceX$, LasReferenceY$, TabReferenceZ$, TabReferenceW$)
End If
End Sub
Sub filternumber(KeyAscii, intnum%)
'Accetta solo numeri
fracsym$ = "."
If intnum% = 1 Then fracsym$ = ""
Select Case Chr$(KeyAscii)
Case "+", "-", fracsym$, "0" To "9", Chr$(8), Chr$(9)
Case Chr$(13)
    KeyAscii = 9
Case Else
    KeyAscii = 0
End Select
End Sub
Sub filesaver(fn$)
Erase TrimMatrix1
ReDim TrimMatrix1(1 To UBound(TrimMatrix))
For i% = 1 To UBound(TrimMatrix)
    TrimMatrix1(i%) = TrimMatrix(i%)
Next i%
Numtrim% = UBound(TrimMatrix)
LasReferenceX$ = TLasReferenceX$
LasReferenceY$ = TLasReferenceY$
LasReferenceX1$ = TLasReferenceX1$
LasReferenceY1$ = TLasReferenceY1$
TabReferenceZ$ = TTabReferenceZ$
TabReferenceW$ = TTabReferenceW$
TabStepZ$ = TTabStepZ$
TabStepW$ = TTabStepW$
NumStepZ$ = TNumStepZ$
NumStepW$ = TNumStepW$
TrimExe$ = TTrimExe$
usepsi$ = Uusepsi$
lastfile$ = fn$
FrmEuro.Caption = fn$
If psistring$ <> "" Then
    un% = FreeFile
    Open thepath1$ + fn$ + ".txt" For Output As un%
        Print #un%, psistring$;
    Close #un%
End If
un% = FreeFile
tm$ = Chr$(13) + Chr$(10)
Open thepath1$ + fn$ + ".dat" For Binary As un%
Close #un%
Open thepath1$ + fn$ + ".dat" For Binary As un%
Put #un%, , LaserVersion$ + tm$
Put #un%, , FileDescription$ + tm$
Put #un%, , LasReferenceX$ + tm$
Put #un%, , LasReferenceY$ + tm$
Put #un%, , LasReferenceX1$ + tm$
Put #un%, , LasReferenceY1$ + tm$
Put #un%, , TabReferenceZ$ + tm$
Put #un%, , TabReferenceW$ + tm$
Put #un%, , TabStepZ$ + tm$
Put #un%, , TabStepW$ + tm$
Put #un%, , NumStepZ$ + tm$
Put #un%, , NumStepW$ + tm$
Put #un%, , TrimExe$ + tm$
Put #un%, , usepsi$ + tm$
filoffset& = Seek(un%)
For i% = 1 To Numtrim%
    myrecord = TrimMatrix(i%)
    Call Putrecord(un%, i%)
Next i%
Close #un%
End Sub
Sub showeditor(tabnum%)
    Load Frmedit
    Frmedit.Visible = False
    Frmedit.Left = EditorX&
    Frmedit.Top = EditorY&
    If tabnum% >= 100 Then
        dis% = 1
        tabnum% = tabnum% - 100
    End If
    If tabnum% >= 0 Then Frmedit.SSTabEdit.Tab = tabnum%
    If dis% = 1 Then
        Frmedit.FramLasRef.Enabled = False
        Frmedit.FramTabRef.Enabled = False
        Frmedit.Cmdsave.Enabled = False
        Frmedit.Cmdres.Enabled = False
        Frmedit.FramTrimNum.Enabled = True
        Frmedit.FramCutType.Enabled = False
        Frmedit.FramCutStart.Enabled = False
        Frmedit.FramCutStop.Enabled = False
        Frmedit.FramCutPar.Enabled = False
        Frmedit.FramlasPar.Enabled = False
        Frmedit.FramTrimBut.Enabled = False
        Frmedit.FramTabStep.Enabled = False
        Frmedit.FramExe.Enabled = False
    Else
        Frmedit.FramLasRef.Enabled = True
        Frmedit.FramTabRef.Enabled = True
        Frmedit.Cmdsave.Enabled = True
        Frmedit.Cmdres.Enabled = True
        Frmedit.FramTrimNum.Enabled = True
        Frmedit.FramCutType.Enabled = True
        Frmedit.FramCutStart.Enabled = True
        Frmedit.FramCutStop.Enabled = True
        Frmedit.FramCutPar.Enabled = True
        Frmedit.FramlasPar.Enabled = True
        Frmedit.FramTrimBut.Enabled = True
        Frmedit.FramTabStep.Enabled = True
        Frmedit.FramExe.Enabled = True
    End If
    Frmedit.ZOrder 0
    Frmedit.Show 1
End Sub
Sub hideeditor()
    Frmedit.Visible = False
    EditorX& = Frmedit.Left
    EditorY& = Frmedit.Top
End Sub
Sub comparerecords(same%)
ll& = Len(myrecord)
thestring1$ = Space$(ll&)
thestring2$ = Space$(ll&)
If same% > 0 Then
    If (same% < UBound(TrimMatrix)) And (same% < UBound(TrimMatrix)) Then
            myrecord1 = TrimMatrix(same%)
            myrecord2 = TrimMatrix1(i%)
            Call CopyMemory(ByVal thestring1$, myrecord1, ll&)
            Call CopyMemory(ByVal thestring2$, myrecord2, ll&)
            If thestring1$ <> thestring2$ Then
                same% = 0
                Exit Sub
            End If
    End If
Else
    thefn1$ = thepath1$ + lastfile$ + ".txt"
    ex$ = ""
    ex$ = Dir$(thefn1$)
    If ex$ <> "" Then
        un% = FreeFile
        Open thefn1$ For Input As #un%
        ll& = LOF(un%)
        npsistring$ = Input$(ll&, un%)
        Close #un%
        If UCase$(psistring$) <> UCase$(npsistring$) Then same% = 0: Exit Sub
    End If
    If UCase$(Trim$(TLasReferenceX$)) <> UCase$(Trim$(LasReferenceX$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TLasReferenceY$)) <> UCase$(Trim$(LasReferenceY$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TLasReferenceX1$)) <> UCase$(Trim$(LasReferenceX1$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TLasReferenceY1$)) <> UCase$(Trim$(LasReferenceY1$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TTabReferenceZ$)) <> UCase$(Trim$(TabReferenceZ$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TTabReferenceW$)) <> UCase$(Trim$(TabReferenceW$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TTabStepZ$)) <> UCase$(Trim$(TabStepZ$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TTabStepW$)) <> UCase$(Trim$(TabStepW$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TNumStepZ$)) <> UCase$(Trim$(NumStepZ$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TNumStepW$)) <> UCase$(Trim$(NumStepW$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(TTrimExe$)) <> UCase$(Trim$(TrimExe$)) Then: same% = 0: Exit Sub
    If UCase$(Trim$(Uusepsi$)) <> UCase$(Trim$(usepsi$)) Then: same% = 0: Exit Sub
    If UBound(TrimMatrix) <> UBound(TrimMatrix1) Then
        same% = 0
        Exit Sub
    End If
    For i% = 1 To UBound(TrimMatrix)
        myrecord1 = TrimMatrix(i%)
        myrecord2 = TrimMatrix1(i%)
        Call CopyMemory(ByVal thestring1$, myrecord1, ll&)
        Call CopyMemory(ByVal thestring2$, myrecord2, ll&)
        If thestring1$ <> thestring2$ Then
            same% = 0
            Exit Sub
        End If
    Next i%
End If
same% = 1
End Sub
Sub checkexe(dr%)
If TTrimExe$ <> "" Then
    NTrimExe$ = TTrimExe$ + ","
    TTrimExe$ = ""
    cm% = 0
    Do
        cm% = InStr(NTrimExe$, ",")
        If cm% > 0 Then
            curfield$ = Left$(NTrimExe$, cm% - 1)
            NTrimExe$ = Mid$(NTrimExe$, cm% + 1)
            drr% = Val(curfield$)
            Select Case drr%
            Case 0, dr%
            Case Is > dr%
                TTrimExe$ = TTrimExe$ + "," + Str$(drr% - 1)
            Case Is < dr%
                TTrimExe$ = TTrimExe$ + "," + Str$(drr%)
            End Select
        End If
    Loop While cm% > 0
    If TTrimExe$ <> "" Then TTrimExe$ = Mid$(TTrimExe$, 2)
End If
End Sub
Sub filleditor(thetrim As trimrecord)
With Frmedit

    .Txtreslabel = cleanval(thetrim.reslabel)
    .txtCurr = cleanval(thetrim.current)
    .txtFreq = cleanval(thetrim.freq)
    .txtCutVal = cleanval(thetrim.ohmvalue)
    .txtScanG = cleanval(thetrim.scang)
    .txtScanH = cleanval(thetrim.scanh)
    .txtScanL = cleanval(thetrim.scanl)
    .txt1st = cleanval(thetrim.cut1St)
    .txtPrestop = cleanval(thetrim.cutPre)
    .TxtTolAccept = cleanval(thetrim.tolaccept)
    .TxtTolCut = cleanval(thetrim.tolcut)
    .txtSpeed = cleanval(thetrim.speed)
    
    
    .lblnumtrim = UBound(TrimMatrix)
    .TxtCutStartX.Tag = cleanval(thetrim.startx)
    .TxtCutStartX = formatter$(step2mm#(Val(cleanval(thetrim.startx)), stepxy!), 3, 2)
    .txtCutStartY.Tag = cleanval(thetrim.starty)
    .txtCutStartY = formatter$(step2mm#(Val(cleanval(thetrim.starty)), stepxy!), 3, 2)
    .txtCutStopX.Tag = cleanval(thetrim.stopx)
    .txtCutStopX = formatter$(step2mm#(Val(cleanval(thetrim.stopx)), stepxy!), 3, 2)
    .txtCutStopY.Tag = cleanval(thetrim.stopy)
    .txtCutStopY = formatter$(step2mm#(Val(cleanval(thetrim.stopy)), stepxy!), 3, 2)
    
    .Chkfunc.value = Val(cleanval(thetrim.func))
    thefunctional% = 0
    If .Chkfunc.value = 1 Then thefunctional% = 1
    'Call rescontinue
    .Txtstep = cleanval(thetrim.serpstep)
    .lsttype.ListIndex = Val(cleanval(thetrim.cutType))
    .lstCutDir.ListIndex = Val(cleanval(thetrim.cutDir))
    .lstslope.ListIndex = Val(cleanval(thetrim.slope))
    .TxtVoltValue = cleanval(thetrim.voltvalue)
    mk$ = cleanval(thetrim.mark)
    For i% = 0 To 2
        .Optmark(i%).value = False
    Next i%
    mk$ = cleanval(thetrim.mark)
    mmkk% = (Val(mk$) - 1)
    If mmkk% < 0 Then mmkk% = 0
    Select Case mmkk%
    Case Is >= 0, Is <= 2
        .Optmark(mmkk%).value = True
    End Select
    .Chkvis.value = Val(cleanval(thetrim.vision))
    'If tmd% = 1 Then
        .txtRefX.Tag = TLasReferenceX$
        .txtRefX = formatter$(step2mm#(Val(TLasReferenceX$), stepxy!), 3, 2)
        .txtRefY.Tag = TLasReferenceY$
        .txtRefY = formatter$(step2mm#(Val(TLasReferenceY$), stepxy!), 3, 2)
        .TxtRefX1.Tag = TLasReferenceX1$
        .TxtRefX1 = formatter$(step2mm#(Val(TLasReferenceX1$), stepxy!), 3, 2)
        .TxtRefY1.Tag = TLasReferenceY1$
        .TxtRefY1 = formatter$(step2mm#(Val(TLasReferenceY1$), stepxy!), 3, 2)
        .txtRefZ.Tag = TTabReferenceZ$
        .txtRefZ = formatter$(step2mm#(Val(TTabReferenceZ$), stepzw!), 3, 2)
        .txtRefW.Tag = TTabReferenceW$
        .txtRefW = formatter$(step2mm#(Val(TTabReferenceW$), stepzw!), 3, 2)
        .txtStepX = TTabStepZ$
        .txtStepY = TTabStepW$
        .txtNstepX = TNumStepZ$
        .txtNstepY = TNumStepW$
        .txtExe = TTrimExe$
        .txtExe.Tag = ""
        .Chkpsi.value = Val(Uusepsi$)
    'End If
End With
If FrmEuro.Imgmacon.Visible = True Then
        sch% = Val(cleanval(thetrim.scanh))
        scl% = Val(cleanval(thetrim.scanl))
        scg% = Val(cleanval(thetrim.scang))
        Call closescan(sch%, scl%, scg%)
        gx& = Val(Frmedit.TxtCutStartX.Tag) + Val(Frmedit.txtRefX.Tag)
        gy& = Val(Frmedit.txtCutStartY.Tag) + Val(Frmedit.txtRefY.Tag)
        gotx$ = Trim$(Str(gx&))
        goty$ = Trim$(Str(gy&))
        Call gotoposxy(gotx$, goty$)
End If

End Sub
Sub getfromeditor(thetrim As trimrecord)
With Frmedit
    TLasReferenceX$ = .txtRefX.Tag
    TLasReferenceY$ = .txtRefY.Tag
    TLasReferenceX1$ = .TxtRefX1.Tag
    TLasReferenceY1$ = .TxtRefY1.Tag
    TTabReferenceZ$ = .txtRefZ.Tag
    TTabReferenceW$ = .txtRefW.Tag
    TTabStepZ$ = .txtStepX
    TTabStepW$ = .txtStepY
    TNumStepZ$ = .txtNstepX
    TNumStepW$ = .txtNstepY
    TTrimExe$ = .txtExe
    Uusepsi$ = Trim$(Str(.Chkpsi.value))
    Call addval(thetrim.reslabel, .Txtreslabel)
    Call addval(thetrim.current, .txtCurr)
    Call addval(thetrim.cut1St, .txt1st)
    Call addval(thetrim.cutPre, .txtPrestop)
    Call addval(thetrim.cutType, Trim$(Str(.lsttype.ListIndex)))
    Call addval(thetrim.cutDir, Trim$(Str(.lstCutDir.ListIndex)))
    Call addval(thetrim.freq, .txtFreq)
    Call addval(thetrim.func, Trim$(Str$(.Chkfunc.value)))
    Call addval(thetrim.serpstep, .Txtstep)
    mk$ = "0"
    For i% = 0 To 2
        If .Optmark(i%).value = True Then
            mk$ = Trim$(Str(i% + 1))
            Exit For
        End If
    Next i%
    Call addval(thetrim.vision, Trim$(Str$(.Chkvis.value)))
    Call addval(thetrim.mark, mk$)
    Call addval(thetrim.ohmvalue, .txtCutVal)
    Call addval(thetrim.scang, .txtScanG)
    Call addval(thetrim.scanh, .txtScanH)
    Call addval(thetrim.scanl, .txtScanL)
    Call addval(thetrim.slope, Trim$(Str(.lstslope.ListIndex)))
    Call addval(thetrim.speed, .txtSpeed)
    Call addval(thetrim.startx, .TxtCutStartX.Tag)
    Call addval(thetrim.starty, .txtCutStartY.Tag)
    Call addval(thetrim.stopx, .txtCutStopX.Tag)
    Call addval(thetrim.stopy, .txtCutStopY.Tag)
    Call addval(thetrim.tolaccept, .TxtTolAccept)
    Call addval(thetrim.tolcut, .TxtTolCut)
    Call addval(thetrim.voltvalue, .TxtVoltValue)
End With
End Sub
Sub nullrecord(thetrim As trimrecord)
With Frmedit
    Call addval(thetrim.current, "")
    Call addval(thetrim.cutType, "5")
    Call addval(thetrim.cutDir, "0")
    Call addval(thetrim.cut1St, "")
    Call addval(thetrim.cutPre, "")
    Call addval(thetrim.freq, "")
    Call addval(thetrim.func, "0")
    Call addval(thetrim.mark, "1")
    Call addval(thetrim.ohmvalue, "")
    Call addval(thetrim.reslabel, "")
    Call addval(thetrim.scang, "")
    Call addval(thetrim.scanh, "")
    Call addval(thetrim.scanl, "")
    Call addval(thetrim.serpstep, "")
    Call addval(thetrim.slope, "1")
    Call addval(thetrim.sparedata, "")
    Call addval(thetrim.speed, "")
    Call addval(thetrim.startx, "")
    Call addval(thetrim.starty, "")
    Call addval(thetrim.stopx, "")
    Call addval(thetrim.stopy, "")
    Call addval(thetrim.tolaccept, "")
    Call addval(thetrim.tolcut, "")
    Call addval(thetrim.vision, "0")
    Call addval(thetrim.voltvalue, "")
End With
End Sub
Sub selectcase()
With Frmedit
Select Case .lsttype.ListIndex
Case 4
    'serp
    .Lbldir.Visible = True
    .lstCutDir.Visible = True
    .Lbl1stop.Visible = False
    .Lblslope.Visible = False
    .txt1st.Visible = False
    .lstslope.Visible = False
    .Txtstep.Visible = True
    .Lblstep.Visible = True
Case 0, 1, 5
'ohmic/functional
.Txtstep.Visible = False
.Lblstep.Visible = False
If .lsttype.ListIndex = 5 Then
    .Lbldir.Visible = False
    .lstCutDir.Visible = False
    .Lbl1stop.Visible = False
    .Lblslope.Visible = False
    .txt1st.Visible = False
    .lstslope.Visible = False
Else
    .Lbldir.Visible = True
    .lstCutDir.Visible = True
    .Lbl1stop.Visible = True
    .txt1st.Visible = True
End If
.Chkfunc.Visible = True
If .Chkfunc.value = 1 Then
    .Lblohm.Visible = False
    .txtCutVal.Visible = False
    .Lblvolt.Visible = True
    .TxtVoltValue.Visible = True
    .Lblslope.Visible = True
    .lstslope.Visible = True
Else
    .Lblohm.Visible = True
    .txtCutVal.Visible = True
    .Lblvolt.Visible = False
    .TxtVoltValue.Visible = False
    .Lblslope.Visible = False
    .lstslope.Visible = False
End If
.FramCutPar.Visible = True
.Frammark.Visible = False
'Case 1
'functional
'Lbldir.Visible = False
'lstCutDir.Visible = False
'FramCutPar.Visible = True
'Lblvolt.Visible = True
'TxtVoltValue.Visible = True
'Lblohm.Visible = False
'txtCutVal.Visible = False'
'Lblslope.Visible = True
'Lbl1stop.Visible = False
'lstslope.Visible = True
'txt1st.Visible = False
'Frammark.Visible = False
Case 2, 3
'mark
'3 circle 4 square
.Txtstep.Visible = False
.Lblstep.Visible = False
.Chkfunc.Visible = False
.Lbldir.Visible = False
.lstCutDir.Visible = False
.FramCutPar.Visible = False
.Frammark.Visible = True
Case 6
'unconditional
.Txtstep.Visible = False
.Lblstep.Visible = False
.Chkfunc.Visible = False
.Lbldir.Visible = False
.lstCutDir.Visible = False
.FramCutPar.Visible = False
.Frammark.Visible = False
End Select
End With
End Sub
