Hello!
I've spent last couple of days programming a new project and it was going so well I was really enjoying the work.
And then, while testing one of the features it crashed. Nothing special, this happens while the script is in developement, so I went and checked it for mistakes. But to my amazement, after quite some time I couldn't locate the problem.
This is the bit where DesktopX Builder crashes in flames:
Code: vbscript
- Dim HKEY_entrynum
- Dim HKEY_written_value
- Dim HKEY_type
- Dim HKEY_visible 'is the entry visible or not (v-visible h-hidden)
- Dim bar_counter
- Dim file 'only file's name
- Sub Reading_HKEY(x)
- m = msgbox("Reading_HKEY"&x,0,"Executro]list ")
- Set Sh = CreateObject("WScript.Shell")
- ' Defining:
- ' -HKEY_written_value
- HKEY_written_value = Sh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Forge7\FIncogniter\index")
- Set Sh = Nothing
- m = msgbox("Read HKEY_written value= "&HKEY_written_value,0,"Executro]list ")
- If HKEY_written_value = "" Or HKEY_written_value ="0|" Then
- m = msgbox("No data available for extraction.",0,"Executro]list ")
- Else
- If x=1 Then
- m=msgbox("create_list(1)",0,"Executro]list ")
- Call create_list(1)
- ElseIf x=2 Then
- m=msgbox("delete_list(2)",0,"Executro]list ")
- Call delete_list(2)
- ElseIf x=3 Then
- m=msgbox("delete_list(3)",0,"Executro]list ")
- Call delete_list(3)
- End If
- End If
- End Sub
- Sub create_list(x)
- bar_counter = 0 'resets bar counter (counts entrys created)
- 'DesktopX.Object("EntryBackground").height = 0 'resets height of the list parent object
- 'DesktopX.Object("EntryBackground").visible = True
- x=split(HKEY_written_value,"|")'segments HKEY to number of entrys and entrys data
- HKEY_entrynum = 0) 'sets number of entrys
- 'DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys = HKEY_entrynum
- DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys = 0
- m = msgbox("Number of actual entrys = "&DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys,0,"Executro]list ")
- m = msgbox("Number of entrys in HKEY = "&HKEY_entrynum,0,"Executro]list ")
- 'If DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys = 0 Then
- Do
- m = msgbox("Just entered the loop",0,"Executro]list ")
- bar_counter = bar_counter+1
- 'splitting entry string to gather data
- y=split( HKEY_entrynum),"*")
- 'Getting wether entry is visible or not (v/h)
- HKEY_visible=y(0)
- 'Getting the type of entry
- HKEY_type=y(1)
- 'Getting full entry name
- HKEY_file=y(2)
- 'Getting only entry's name
- z = InStrRev(HKEY_file,"\","-1")'now x is the number where string needs to be cut
- q = Len(HKEY_file)
- file = Right(HKEY_file,(q-z))'This is only entry's name
- HKEY_entrynum = HKEY_entrynum - 1 'ensures that during next pass new entry will be managed
- 'now cloning objects:
- 'EntryParent*x
- DesktopX.Object("EntryParent*0").clone ("EntryParent*"&bar_counter), DesktopX.Object("EntryParent*0").left, (-DesktopX.Object("EntryParent*0").height+(bar_counter*DesktopX.Object("EntryParent*0").height))
- 'm = msgbox("HKEY_visible: "&DesktopX.ScriptObject("EntryParent*"&bar_counter).HKEY_visible,0,"Executor]list ")
- DesktopX.ScriptObject("EntryParent*"&bar_counter).HKEY_visible = HKEY_visible
- 'm = msgbox("HKEY_visible: "&DesktopX.ScriptObject("EntryParent*"&bar_counter).HKEY_visible,0,"Executor]list ")
- DesktopX.ScriptObject("EntryParent*"&bar_counter).HKEY_type = HKEY_type
- DesktopX.ScriptObject("EntryParent*"&bar_counter).HKEY_file = HKEY_file
- DesktopX.ScriptObject("EntryParent*"&bar_counter).file = file
- 'EntryChild*x
- DesktopX.Object("EntryChild*0").clone ("EntryChild*"&bar_counter), DesktopX.Object("EntryChild*0").left, DesktopX.Object("EntryChild*0").top
- DesktopX.Object("EntryChild*"&bar_counter).parent = DesktopX.Object("EntryParent*"&bar_counter)
- 'EntryToolboxMask*x
- DesktopX.Object("EntryToolboxMask*0").clone ("EntryToolboxMask*"&bar_counter), DesktopX.Object("EntryToolboxMask*0").left, DesktopX.Object("EntryToolboxMask*0").top
- DesktopX.Object("EntryToolboxMask*"&bar_counter).parent = DesktopX.Object("EntryParent*"&bar_counter)
- 'EntryToolbox*x
- DesktopX.Object("EntryToolbox*0").clone ("EntryToolbox*"&bar_counter), DesktopX.Object("EntryToolbox*0").left, DesktopX.Object("EntryToolbox*0").top
- DesktopX.Object("EntryToolbox*"&bar_counter).parent = DesktopX.Object("EntryToolboxMask*"&bar_counter)
- 'EntryText*x
- DesktopX.Object("EntryText*0").clone ("EntryText*"&bar_counter), DesktopX.Object("EntryText*0").left, DesktopX.Object("EntryText*0").top
- DesktopX.Object("EntryText*"&bar_counter).parent = DesktopX.Object("EntryChild*"&bar_counter)
- DesktopX.Object("EntryText*"&bar_counter).text = file
- 'EntryVisibility*x
- DesktopX.Object("EntryVisibility*0").clone ("EntryVisibility*"&bar_counter), DesktopX.Object("EntryVisibility*0").left, DesktopX.Object("EntryVisibility*0").top
- DesktopX.Object("EntryVisibility*"&bar_counter).parent = DesktopX.Object("EntryToolbox*"&bar_counter)
- If HKEY_visible = "v" Then
- DesktopX.ScriptObject("EntryVisibility*"&bar_counter).switcher = "v"
- DesktopX.ScriptObject("EntryVisibility*"&bar_counter).active = True
- DesktopX.Object("EntryVisibility*"&bar_counter).ExecuteCommand
- End If
- 'EntryType*x
- DesktopX.Object("EntryType*0").clone ("EntryType*"&bar_counter), DesktopX.Object("EntryType*0").left, DesktopX.Object("EntryType*0").top
- DesktopX.Object("EntryType*"&bar_counter).parent = DesktopX.Object("EntryChild*"&bar_counter)
- DesktopX.Object("EntryType*"&bar_counter).state = HKEY_type
- 'EntryRun*x
- DesktopX.Object("EntryRun*0").clone ("EntryRun*"&bar_counter), DesktopX.Object("EntryRun*0").left, DesktopX.Object("EntryRun*0").top
- DesktopX.Object("EntryRun*"&bar_counter).parent = DesktopX.Object("EntryToolbox*"&bar_counter)
- 'EntryRemove*x
- DesktopX.Object("EntryRemove*0").clone ("EntryRemove*"&bar_counter), DesktopX.Object("EntryRemove*0").left, DesktopX.Object("EntryRemove*0").top
- DesktopX.Object("EntryRemove*"&bar_counter).parent = DesktopX.Object("EntryToolbox*"&bar_counter)
- 'EntryFolder*x
- DesktopX.Object("EntryFolder*0").clone ("EntryFolder*"&bar_counter), DesktopX.Object("EntryFolder*0").left, DesktopX.Object("EntryFolder*0").top
- DesktopX.Object("EntryFolder*"&bar_counter).parent = DesktopX.Object("EntryToolbox*"&bar_counter)
- DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys = DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys+1
- Loop until HKEY_entrynum=0
- m = msgbox("Done compiling the list",0,"Executor]list ")
- x="1"
- y="1"
- z="1"
- m = msgbox("x ="&x&vbnewline&"y ="&y&vbnewline&"z ="&z,0,"Executor]list ")
- End Sub
- Sub delete_list(x)
- If DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys = 0 Then
- m = msgbox("(=0)number_of_actual_entrys = "&number_of_actual_entrys,0,"Executro]list ")
- Else
- m = msgbox("( 0)number_of_actual_entrys = "&number_of_actual_entrys,0,"Executro]list ")
- 'y=split(HKEY_written_value,"|")'segments HKEY to number of entrys and entrys data
- 'HKEY_entrynum = y(0) 'sets number of entrys
-
- 'This is not hkey value but rather the real value!
- HKEY_entrynum = DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys
- If x = 3 Then
- 'HKEY_entrynum = HKEY_entrynum-1 ' I just removed this one
- End If
- m = msgbox("HKEY_entrynum = "&HKEY_entrynum,0,"Executro]list ")
- Do
- DesktopX.Object("EntryFolder*"&HKEY_entrynum).delete
- DesktopX.Object("EntryRemove*"&HKEY_entrynum).delete
- DesktopX.Object("EntryVisibility*"&HKEY_entrynum).delete
- DesktopX.Object("EntryRun*"&HKEY_entrynum).delete
- DesktopX.Object("EntryText*"&HKEY_entrynum).delete
- DesktopX.Object("EntryType*"&HKEY_entrynum).delete
- DesktopX.Object("EntryToolbox*"&HKEY_entrynum).delete
- DesktopX.Object("EntryToolboxMask*"&HKEY_entrynum).delete
- DesktopX.Object("EntryChild*"&HKEY_entrynum).delete
- DesktopX.Object("EntryParent*"&HKEY_entrynum).delete
-
- HKEY_entrynum = HKEY_entrynum-1
- DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys = DesktopX.ScriptObject("EntryBackground").number_of_actual_entrys-1
- Loop until HKEY_entrynum = 0
-
- If x = 3 Then
- m = msgbox("(1)Just deleted the list, now calling Reading_HKEY(1)",0,"Executro]list ")
- Call Reading_HKEY(1)
- End If
- End If
- If x = 3 Then
- m = msgbox("(pass one)(2)Just deleted the list, now calling Reading_HKEY(1)"&vbnewline&"x = "&x,0,"Executro]list ")
- If x = 3 Then
- m = msgbox("(pass two)(3)Just deleted the list, now calling Reading_HKEY(1)"&vbnewline&"x = "&x,0,"Executro]list ")
- Call Reading_HKEY(1)
- End If
- End If
- End Sub
(Some things are unnecessary, but I added them to see if they would help...)
Now it works like this, this script is assigned to an object and it is called by others depending on what needs to be done.
This is how it is supposed to work:
1. Sub delete_list(x) is called form another object.
2. Sub ends and calls Sub Reading_HKEY(1)
3. Sub ends and calls Sub create_list(x)
4. Sub ends and that concludes the operation.
However, when launched this happens:
1. Sub delete_list(x) is called form another object.
2. Sub ends and calls Sub Reading_HKEY(1)
3. Sub ends and calls Sub create_list(x)
*now watch closely
4. it doesn't call Sub delete_list(x) but it immediately jumps to somewhere around line(140) although it wasn't even supposed to do that. After that, despite the "If" regulation which should stop the flow, it calls Sub Reading_HKEY(1), and then after reaching the end DesktopX Builder crashes.
Now just to make me even more confused, sometimes it even works (if i try Calling different Subs outside the object) but ultimately it just crashes.
I tried all sorts of things, I even tried moving one sub to another object, even removing entire contents of the sub except the crucial part, and it still wouldn't work and crash in the same or similar manner.
Now can anyone find the problem/bug or at least suggest a solution? I can even send you entire program if you think that would help.
If anyone has any, and I mean any idea, please post it here, so I can try to fix this bug.
P.S. thank you for reading this