Solved

deleteItem is not deleting the item

Posted on 2008-10-01
10
498 Views
Last Modified: 2013-12-26
Hi,
I'm using PB10.5
The attached code starts out by filling the ddlb w/ names of all folders and files(which I don't really want but am not sure how to avoid bringing in).  Then since all the folder names are surrounded by brackets when brought into the ddlb, the first loop in the code takes the brackets off.
The second loop is where the problem is located. First it checks if the sheetname is less than 8 char long. If it is less than 8 then it deletes it from the ddlb. This part works.
Else, if the sheetname does not start with 2 numbers and a letter then it should delete the item. This part DOES NOT work. When I debug the sheets that do not start w/ nbr,nbr,letter are caught in the IF statement and it gets into the "ddlb_sheet.deleteitem(i)" line and it looks like everything is working fine, but when the window comes up and I click the ddlb all the names are still there(except the ones that are less than 8 because that part works).

Any Ideas on this?

Thx,
Dave
//get sheet names from folders on harddrive.

ddlb_sheet.DirList("C:\Digital",16)
 
 

//clean-up sheet names in ddlb_sheet.

i = 1

maxRowCnt = ddlb_sheet.TotalItems()
 

do until i = maxRowCnt + 1

	ddlb_sheet.SelectItem(i)

	sCurrSheet = Trim(ddlb_sheet.Text(i))

	iSheetChars = Len(sCurrSheet)

	sCleanSheet = Mid(sCurrSheet,2,(iSheetChars - 2))

	ddlb_sheet.deleteitem(i)

	ddlb_sheet.additem(sCleanSheet)

	i = i+1

loop
 
 

//filter out non-sheets from ddlb_sheet

i = 1

maxRowCnt = ddlb_sheet.TotalItems()
 

do until i = maxRowCnt + 1

	

	ddlb_sheet.SelectItem(i)

	sCurrSheet = Trim(ddlb_sheet.Text(i))

	iSheetChars = Len(sCurrSheet)

	

	If iSheetChars < 8 then

		ddlb_sheet.deleteitem(i)

	else

		if not match(sCurrSheet, "^[0-9][0-9][A-Za-z]") then

			ddlb_sheet.deleteitem(i)

		end if

	end if

	i = i + 1

loop

Open in new window

0
Comment
Question by:coperations07
  • 5
  • 5
10 Comments
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 22625426
Ok...The problem is that you are deleting items and increasing value of i hence it is skipping the items..change you conditions like below....

//filter out non-sheets from ddlb_sheet
maxRowCnt = ddlb_sheet.TotalItems()
i = maxRowCnt
do until i = 0
      ddlb_sheet.SelectItem(i)
      sCurrSheet = Trim(ddlb_sheet.Text(i))
      iSheetChars = Len(sCurrSheet)
      If iSheetChars < 8 then
            ddlb_sheet.deleteitem(i)
      else
            if not match(sCurrSheet, "^[0-9][0-9][A-Za-z]") then
                  ddlb_sheet.deleteitem(i)
            end if
      end if
      i = i - 1
loop

Regards,
Sandeep
0
 

Author Comment

by:coperations07
ID: 22628157
I switched the code, but the items are still not deleting and showing up in the ddlb. I attached a couple of screen shots from when I debugged.

thx,
Dave
Doc1.doc
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 22635674
I doubt, you also changed
i = maxRowCnt and placed after maxRowCnt = ddlb_sheet.TotalItems() ???

see in my previous comment. If you have already changed it let us know what are all files and folders under 'c:\digital' Hence i can replicate in my local machine with the same code.

Regards,
Sandeep

0
 

Author Comment

by:coperations07
ID: 22636252
I attached the code that I have now. I did change the row count variables.
I also attached a screen shot of the file & folder names on C:Digital.
//filter out non-sheets from ddlb_sheet
 

maxRowCnt = ddlb_sheet.TotalItems()

i = maxRowCnt

do until i = 0

	

	ddlb_sheet.SelectItem(i)

	sCurrSheet = Trim(ddlb_sheet.Text(i))

	iSheetChars = Len(sCurrSheet)

	

	If iSheetChars < 8 then

		ddlb_sheet.deleteitem(i)

	else

		if not match(sCurrSheet, "^[0-9][0-9][A-Za-z]") then

			ddlb_sheet.deleteitem(i)

		end if

	end if

	

	i = i - 1

loop

Open in new window

Doc1.doc
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 22636665
Really wierd...works great in my system...Here is the screen shot and code attached. Try once more copying the same code from document.

I m using PB 10.5 Build 4523
ee-deleteitem.doc
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Expert Comment

by:sandeep_patel
ID: 22636760
put,
ll_return = ddlb_sheet.deleteitem(i)
and check value of ll_return in debug mode
0
 

Author Comment

by:coperations07
ID: 22637834
(insert frustrated smiley face here...banging head on keyboard)

I commented out the code I had and pasted yours in. Then I ran it and it still fiiled the ddlb w/ all the items except the ones that were < 8.  I put ll_return in there and it ends up w/ a value of 10 which is the number of items that should be in the box.  Everytime it got into the if statement the ll_return would subtract 1. But still all the items showed in the ddlb.

Now this next part is what's really throwing me for a loop (pardon the pun).
I took out the code that deletes the items that are < 8. But it changed nothing. All the items < 8 still get deleted, but none of the rest!?!?? I'm completely lost.
0
 

Author Comment

by:coperations07
ID: 22637908
Geez. I took the whole loop out and ran it. The items < 8  are still getting taken out even without the loop that takes them out. So I added a new folder called "00000000" and ran it. The new folder showed up in the box. Then I renamed it "0000" and it still shows up, but not the other ones that are less than 8 chars. It's like it's stuck in memory or something.
0
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 350 total points
ID: 22638084
Are you sure you don't have any other code which populates this ddlb. Or is this the same ddlb you are referencing in code?

I know I am asking very foolish questions. But sometimes we do mistake.
Few tests...

1. make sure you don't have the other copy of the same window with same name
2. Once do full build.
3. First keep the code to remove brackets. Then add the code to delete items which are less than 8 chars. then add code to remove items for other conditions.
in other PBLs
4. In code change ddlb_sheet to ddlb_sheet1 and then hit save it will give error then go to layout and change the name of this ddlb.
5. create some sample window, put ddlb and a command button and test on that window.

Hope you will find something.
0
 

Author Comment

by:coperations07
ID: 22650507
Well...guess I just needed a weekend to refresh.
I found what the problem was. The code we had been looking at was tied to the open event of the window. There are also 2 option buttons on the window with code that changes the contents of the ddlb when they are ticked. I hadn't thought about that event getting triggered when the form opened, but I guess it does. The code in the option button was the same as what I had in the open event to fill the ddlb, but then I added the Match function and it wasn't in the option button. The only reason I realized what was happening was because I accidentally clicked the other option button while I was going through your steps(sandeep) and I realized that the contents of the ddlb changed when I clicked the option button.

Maybe I'm not going crazy after all...

Thanks for all the help,
Dave
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now