im stuck

Mookie_jones

Member
Joined
Oct 23, 2005
Messages
16
Programming Experience
Beginner
I know you guys arent here to fix my code... but i have run into a problem


what i am doing is using a treeview to read a file that has been loaded into a text box.

everytime the word ";fold" appears, it will create a new treenode and add children to it until the word ";endfold" appears.

I have it working good up to the point of adding folds within folds.

i can get on into it but the second fold within is where i am having the trouble.

here is the code that i have

VB.NET:
Private Sub rtb_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rtb.TextChanged
  
          If donechanging = False Then
              Dim i, a As Integer
              Dim newname As String
              tv.Nodes.Clear()
              tv.BeginUpdate()
              Dim nodeinfo() As String
              Dim nodename As String
              Dim temp() As String
              For i = 0 To rtb.Lines.Length - 1
                 If InStr(UCase(rtb.Lines(i)), ";FOLD") Then
                     Dim tvnode As New TreeNode
                     temp = Split(UCase(rtb.Lines(i)), ";FOLD")
                     temp(1) = Trim(temp(1))
  
                     If temp(1).Trim.Substring(0, 1) = ";" Then
                        temp = Split(temp(1).Trim, ";")
                        nodename = temp(1)
                        tvnode = Me.tv.Nodes.Add(temp(1))
                        tvnode.Nodes.Add(rtb.Lines(i))
                      Else
                        nodename = temp(1)
                        temp = Split(temp(1), ";") ' added for moves 
                        tvnode = Me.tv.Nodes.Add(temp(0)) ' was a 1, now a 0 for movement 
                        tvnode.Nodes.Add(rtb.Lines(i))
                      End If
  
  
  
                     While (i <= rtb.Lines.Length - 1) And (InStr(UCase(rtb.Lines(i)), ";ENDFOLD") = False)
  
                        If InStr(UCase(rtb.Lines(i)), ";ENDFOLD") = False Then
                            i = i + 1
  
                        End If
  
                        ' need to find fold within fold
                        If InStr(UCase(rtb.Lines(i + 1)), ";FOLD") Then
                            tvnode.Nodes.Add(rtb.Lines(i))
  
                            While (i <= rtb.Lines.Length - 1) And (InStr(UCase(rtb.Lines(i)), ";ENDFOLD") = False)
  
  
  
                                If InStr(UCase(rtb.Lines(i)), ";ENDFOLD") = False Then
                                    i = i + 1
  
                                End If
  
                                If InStr(UCase(rtb.Lines(i)), ";FOLD") Then
                                    temp = Split(UCase(rtb.Lines(i)), ";FOLD")
                                    temp(1) = Trim(temp(1))
  
                                    If temp(1).Trim.Substring(0, 1) = ";" Then
                                        temp = Split(temp(1).Trim, ";")
                                        nodename = temp(1)
                                        tvnode = tvnode.Nodes.Add(temp(1)) ' was a 1, now a 0 for movement 
  
                                    Else
                                        nodename = temp(1)
                                        temp = Split(temp(1), ";") ' added for moves 
                                        tvnode = tvnode.Nodes.Add(temp(0)) ' was a 1, now a 0 for movement
                                        tvnode.Nodes.Add(rtb.Lines(i))
                                    End If
                                Else
                                    If InStr(LCase(rtb.Lines(i)), ";endfold") = False Then
  
                                        tvnode.Nodes.Add(rtb.Lines(i))
                                    End If
  
                                End If
  
                                ' need to find one more fold within fold 
  
                            End While
                            
                        End If
                        If InStr(LCase(rtb.Lines(i)), ";endfold") = False Then
                            tvnode.Nodes.Add(rtb.Lines(i))
                        End If
  
  
                        ' is speed ptp?
  
                      End While
                  Else
                     If InStr(LCase(rtb.Lines(i)), ";endfold") Then
                      Else
  
                        tv.Nodes.Add(rtb.Lines(i))
                        myselectednode = tv.Nodes(tv.Nodes.Count - 1)
                        myselectednode.BeginEdit()
                        tv.Parent.ForeColor = Color.Orange
                        myselectednode.EndEdit(False)
  
                      End If
                  End If
              Next
  
              tv.EndUpdate()
              ' rtb.Enabled = False
              donechanging = True
          End If
      End Sub
 

Mookie_jones

Member
Joined
Oct 23, 2005
Messages
16
Programming Experience
Beginner
heres a file of text that would go along with it to be read in



VB.NET:
&ACCESS RVP
&REL 37
&COMMENT TIPDRESS FUNCTION
DEF  TIPDRESS1 ( )
;FOLD INI;%{PE}%V2.3.0,%MKUKATPBASIS,%CINIT,%VCOMMON,%P
;===================================
; SHELL - Package KR C1
; Version 1.2.3
; Date: 03.11.98
;===================================
MODE=#SYNC
IF $PRO_STATE0<>#P_ACTIVE THEN
CWRITE($CMD,STAT,MODE,"RUN /R1/BACKGRND ()")
ENDIF
OFFSET=0
SWRITE(LOGMESS1.STYLE[],STATE,OFFSET,"%S",$PRO_IP.NAME[])
OFFSET=0
;FOLD BAS INI;%{PE}%V2.3.0,%MKUKATPBASIS,%CINIT,%VINIT,%P
BAS (#INITMOV,0 )
;ENDFOLD
;FOLD USER INI;%{P}%V2.2.2,%MKUKATPUSER,%CINIT,%VINIT,%P
;Make your modifications here
APPL_INI ( )
;ENDFOLD
;ENDFOLD

;FOLD Segment.Set_Path_Segment_AtPos Number4;%{PE}%MKUKATPUSER
SET_PATH_SEG (0,4)
;ENDFOLD

;FOLD PTP HOME  Vel= 100 % DEFAULT;%{PE}%V2.2.2,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
$H_POS=XHOME
PDAT_ACT=PDEFAULT
BAS (#PTP_DAT )
FDAT_ACT=FHOME
BAS (#FRAMES )
BAS (#VEL_PTP,100 )
PTP  XHOME
;ENDFOLD
;FOLD PTP P2  Vel= 100 % PDAT2 Tool[1]:Servo Gun Base[0];%{PE}%R 5.2.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P2, 3:, 5:100, 7:PDAT2
$BWDSTART = FALSE
PDAT_ACT=PPDAT2
FDAT_ACT=FP2
BAS(#PTP_PARAMS,100)
PTP XP2
;ENDFOLD
;FOLD PTP P3  Vel= 100 % PDAT3 Tool[1]:Servo Gun Base[0];%{PE}%R 5.2.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P3, 3:, 5:100, 7:PDAT3
$BWDSTART = FALSE
PDAT_ACT=PPDAT3
FDAT_ACT=FP3
BAS(#PTP_PARAMS,100)
PTP XP3
;ENDFOLD
;FOLD TipDress.CheckTips Gun=1, Measure Type=[Before Dress];%{PE}%MKUKATPUSER
$BWDSTART=TRUE
EG_EXTAX_ACTIVE=EG_SERVOGUN_EXAXIS[1]
BAS (#FRAMES)
P_INIT=$POS_ACT
PTP P_INIT
CMD=#INIT_CYC
EG_SPOT_POINT=P_INIT
USERTIPDRESS (#Tip_Reference,1,1)
PTP P_INIT
;ENDFOLD
;FOLD PTP P6  Vel= 100 % PDAT6 Tool[1]:Servo Gun Base[0];%{PE}%R 5.2.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P6, 3:, 5:100, 7:PDAT6
$BWDSTART = FALSE
PDAT_ACT=PPDAT6
FDAT_ACT=FP6
BAS(#PTP_PARAMS,100)
PTP XP6
;ENDFOLD

;FOLD TipDress.Motor Tip Dresser:1, Motor:On;%{PE}%MKUKATPUSER
USERTIPDRESS (#START_MOTOR,1,1)
;ENDFOLD

;FOLD SG_TipDress.P_LIN SGtipdress, Vel=1 m/s, Accl=100 %, Gun=1, Part=9 mm, Force=300 lbs, Eqlzr=1, EqRst=0 mm, Tool[1], Base[0], ExtTCP[False];%{PE}%MKUKATPUSER
$BWDSTART=TRUE
LDAT_ACT=LSGtipdressDAT
FDAT_ACT=FSGtipdress
BAS (#CP_PARAMS,1)
EG_EXTAX_ACTIVE=EG_SERVOGUN_EXAXIS[1]
EG_THICKNESS=9
EG_GUN_FORCE=300*rl_CONVERSION_FACTOR
EG_COMP_HELP=1
EG_COMPENSATE_PATH=0
EG_HELPPOINT=EG_CHTIP(SGtipdress)
LIN EG_HELPPOINT
CMD=#TIP_DRESSING
EG_SPOT_POINT=EG_HELPPOINT
EG_SPOT( )
LIN EG_HELPPOINT
CMD=#STOP_POINT_END
EG_SPOT_POINT=EG_HELPPOINT
EG_SPOT( )
;ENDFOLD

;FOLD TipDress.Motor Tip Dresser:1, Motor:Off;%{PE}%MKUKATPUSER
USERTIPDRESS (#STOP_MOTOR,1,1)
;ENDFOLD

;FOLD PTP P7  Vel= 100 % PDAT7 Tool[1]:Servo Gun Base[0];%{PE}%R 5.2.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P7, 3:, 5:100, 7:PDAT7
$BWDSTART = FALSE
PDAT_ACT=PPDAT7
FDAT_ACT=FP7
BAS(#PTP_PARAMS,100)
PTP XP7
;ENDFOLD
;FOLD PTP P8  Vel= 100 % PDAT8 Tool[1]:Servo Gun Base[0];%{PE}%R 5.2.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P8, 3:, 5:100, 7:PDAT8
$BWDSTART = FALSE
PDAT_ACT=PPDAT8
FDAT_ACT=FP8
BAS(#PTP_PARAMS,100)
PTP XP8
;ENDFOLD
;FOLD PTP P4  Vel= 100 % PDAT4 Tool[1]:Servo Gun Base[0];%{PE}%R 5.2.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P4, 3:, 5:100, 7:PDAT4
$BWDSTART = FALSE
PDAT_ACT=PPDAT4
FDAT_ACT=FP4
BAS(#PTP_PARAMS,100)
PTP XP4
;ENDFOLD
;FOLD TipDress.CheckTips Gun=1, Measure Type=[After Dress];%{PE}%MKUKATPUSER
$BWDSTART=TRUE
EG_EXTAX_ACTIVE=EG_SERVOGUN_EXAXIS[1]
BAS (#FRAMES)
P_INIT=$POS_ACT
PTP P_INIT
CMD=#INIT_CYC
EG_SPOT_POINT=P_INIT
USERTIPDRESS (#Tip_Measure,1,1)
PTP P_INIT
;ENDFOLD
;FOLD PTP P5  Vel= 100 % PDAT5 Tool[1]:Servo Gun Base[0];%{PE}%R 5.2.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P5, 3:, 5:100, 7:PDAT5
$BWDSTART = FALSE
PDAT_ACT=PPDAT5
FDAT_ACT=FP5
BAS(#PTP_PARAMS,100)
PTP XP5
;ENDFOLD
;FOLD PTP HOME  Vel= 100 % DEFAULT;%{PE}%V2.2.2,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
$H_POS=XHOME
PDAT_ACT=PDEFAULT
BAS (#PTP_DAT )
FDAT_ACT=FHOME
BAS (#FRAMES )
BAS (#VEL_PTP,100 )
PTP  XHOME
;ENDFOLD
 
Top Bottom