lsp doesnt work when dialog called from another dialog

Started by andrew, February 09, 2010, 12:29:27 PM

Previous topic - Next topic

andrew

this is a strange thing happening so ill do my best to explain the issue
apologies in advanced if its not enough explaination.

attached are the files for examination.
the code in question is at the very botton of the text file
commented as  ;;;;stock book search;;;

when i run the full program all works.

the problem happens when i press a button called "stock book".

when the dialog opens, i do a search for the text im after.
when i find the text i double click that line and its supposed to close the dialog and allow me to copy the text from the list its reading from and replacing a selected line of text in acad.

the lsp code doesnt work when i activate that dialog box by pressing the text button, however if i activate the dialog by typing in
(dcl_Form_Show dwgbrowser_stockbook) in the command line
and then going thru my process, it all works how it was designed.

would anyone have a clue as to whats going on, why its doing this?
what did i do wrong?

any help is appreciated

owenwengerd

Have you tried changing the Event Invoke property of the button?
Owen Wengerd (Outside The Box) / ManuSoft

andrew

Quote from: owenwengerd on February 09, 2010, 02:57:05 PM
Have you tried changing the Event Invoke property of the button?

no i havent
what would this do by changing it?

owenwengerd

Owen Wengerd (Outside The Box) / ManuSoft


owenwengerd

What exactly doesn't work? Do you get any error messages?
Owen Wengerd (Outside The Box) / ManuSoft

andrew

Quote from: owenwengerd on February 12, 2010, 09:21:27 AM
What exactly doesn't work? Do you get any error messages?

no error messages.

the lisp executes but then doesnt let me select the text to "swap" out for the text it grabbed from a text file.
the way i explained it makes it sound like its the lisp code, but like i said in the first post, if i run the dialog manually, it does work if the dialog is called from another dialog the code dont work


andrew


owenwengerd

I think it would be easier to help you if you could create a simple project from scratch with only the bare minimum code to demonstrate the problem.  I loaded your project, but I could not figure out what to do next.  When I tried typing some text and searching, I got an error about a missing (doslib?) function.
Owen Wengerd (Outside The Box) / ManuSoft

andrew

i used doslib for a print function...

anyway here is a stripped down version
you will need to change the text path (f:\\stock\\partdes.txt)
to look for your test text file

this does the same thing, if you press the text button to bring up the search form it works but then when its time for the copying of the text from the search form to acad i cant select any text in acad
however if you call the form manually without calling the main form.

(dcl_Form_Show STKBK_stockbook)

the function performs hows its supposed to


owenwengerd

I didn't try the new files yet, but I noticed the following in your lisp file:
Code (autolisp) Select
(defun c:STKBK_Form1_TextButton1_OnClicked (/)
(dcl_Form_Close STKBK_Form1)
(dcl_Form_Show STKBK_stockbook)
)


That is a recipe for disaster, because you're showing a new form before the first form has completely closed. I suspect this is the reason you're having trouble. The correct way to handle this is to open the second form after the first (dcl_Form_Show) returns. You can do that conditionally depending on the return value of (dcl_Form_Show), and you can specify whatever return value you want in your call to (dcl_Form_Close).
Owen Wengerd (Outside The Box) / ManuSoft

owenwengerd

Never mind. I assumed your form1 was a modal dialog, but I see it is modeless. For a modeless dialog, it should work to show another dialog from within an event handler.

Since I don't have a partdes.txt file, the file doesn't work the same for me as it does for you, and I still don't see the problem. Please upload a version with some hardcoded values in the list and describe step by step what I need to do to see the problem.
Owen Wengerd (Outside The Box) / ManuSoft

andrew

Owen,
attached is the partsdes.txt file i only has a few items in it but i think this will be enough to get it working, you will just have to adjust the path.

here is hows its supposed to work
after the program is loaded, you call it up.
it brings up form1 with "textbutton1" (obviously)
1 - you then press that button and it calls the stock book search form
2- enter your search, you will need to enter something thats in the partsdes.txt file for example, you would type in  1" IPS
then press the search button
3 - the results are displayed in the list box, for example:
93 03000 092 06 18 10   1" IPS SCH 40 A-53 B WELDED PIPE

4 - you double click on one of the lines. after you double click your selection it allows you to pick a text entity and will change that text entity with the stock number. (this is where is stops working)
it goes into the function to allow you to select but doesnt select.

now if you were to call just that form (dcl_Form_Show STKBK_stockbook)
manually from the command line.
and repeat the steps above, the program works as it was intended.

i hope this is a little better explaination.

thanks again

owenwengerd

I tried what you wrote, but I don't get any search results.  However, I think you're encountering the problem I mentioned earlier, jus in a different place.  Try this:
Close the second form like this:
(dcl_Form_Close STKBK_stockbook 5)

Then, move your text changing code to your OnClicked function like this:

(if (= 5 (dcl_Form_Show STKBK_stockbook))
;change text here -- you may need to save the text in a global variable
)

The idea is to do the work *after* (dcl_Form_Close) returns.
Owen Wengerd (Outside The Box) / ManuSoft

andrew

i dont follow what that code is supposed to do

i changed per your suggestions and it still didnt work