Memory problems

Something appears to be wrong with my loop logic here. It opens programs before closing the last one. This eventually causes a crash. It works wonderfully if I am just modifying 1 program. I apologize, I have never used Basic before.

Sub Main()

Dim App As Object

Dim Parts As Object

Dim Part As Object

Dim CMDs As Object

Dim CMD As Object

Dim strOldPrb (160) As String

Dim strNewPrb (160) As String

Dim IdNam As String

strOldPrb(1) = “T1A100B87.5”

strOldPrb(2) = “T1A-100B90”


strOldPrb(158) = “T1A-30B-2.5”

strOldPrb(159) = “T1A45B177.5”

strNewPrb(1) = “T1A105B90”

strNewPrb(2) = “T1A-105B90”


strNewPrb(158) = “T1A-30B0”

strNewPrb(159) = “T1A45B180”

sPath = “C:test”

Set App=CreateObject(“PCDLRN.Application”)

Set Parts=App.PartPrograms

sFile=Dir(sPath & “*.prg”)

Do While sFile <> “”

If sFile <> “.” And sFile <> “..” Then

sName = sPath & sFile

Set Part = Parts.Open(sName, “Machine1”)

Set Cmds = Part.Commands

For Each Cmd In Cmds

If Cmd.IsActiveTip Then

IdNam = Cmd.GetText(REF_ID, 0)

For i = 1 To 159

If IdNam = strOldPrb(i) Then

retval = Cmd.PutText(strNewPrb(i), REF_ID, 0)

End If


End If


Set Cmd = Nothing

Set Cmds = Nothing



Set Part = Nothing

End If

sFile = Dir


End Sub

Information can be found here on the commands I am using, but I am not sure they are relevant to the problem.

submitted by /u/Cowrevenge
[link] [comments]

Leave a Reply