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
Have you tried changing the Event Invoke property of the button?
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?
See here for more information about Event Invoke:
http://www.opendcl.com/HelpFiles/index.php?page=Reference/Property/EventInvoke.htm (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Property/EventInvoke.htm)
Quote from: owenwengerd on February 12, 2010, 08:26:58 AM
See here for more information about Event Invoke:
http://www.opendcl.com/HelpFiles/index.php?page=Reference/Property/EventInvoke.htm (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Property/EventInvoke.htm)
thanks Owen, however that didnt help.
its still not working
What exactly doesn't work? Do you get any error messages?
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
any other solutions?
has anyone tested this yet?
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.
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
I didn't try the new files yet, but I noticed the following in your lisp file:
(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).
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,
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
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.
i dont follow what that code is supposed to do
i changed per your suggestions and it still didnt work
See if this helps:
http://www.opendcl.com/forum/index.php?topic=1080.0 (http://www.opendcl.com/forum/index.php?topic=1080.0)
i understood that, but closing the modal form to allow for selecting still didnt work.
this is frustrating... :-\
Hello, andrew,
I attached a completely rewritten code. Check it out. It works quite well for me.
Have a closer look at this topic (http://www.opendcl.com/forum/index.php?topic=947.0).
Fred
Hi Fred,
thanks for your reply
im checking out that link you posted now
i tested your modification to the code and after i close the search dialog i notice it still leaves me in the command (somewhat) what i mean is it doesnt leave me at a command prompt it still looks like im in the selection command.
also i noticed in the code you used
(dcl_Form_Close STKBK_stockbook 3)
similar to what Owen has suggested
what does the 3 mean
1 and 2 is explained in the helps but i didnt see 3
if i were to change the 3 to a 1 would that exit me out of the while loop when i press enter?
thanks again for your assistance
also
i noticed that after i press enter and it reinitializes the stock book
this line
(dcl_Control_SetText STKBK_stockbook_TextBox1 "")
which is supposed to clear the search entry on initialize doesnt clear it
Hi, andrew,
Quote from: andrew on February 18, 2010, 06:03:07 AM
i tested your modification to the code and after i close the search dialog i notice it still leaves me in the command (somewhat) what i mean is it doesnt leave me at a command prompt it still looks like im in the selection command.
Yes, that's right. It's because the subform is starting from an event calling by a control which property EventInvoke was set to KeepFocus.
That's a real mess of this code: there is an OnClick event. During the OnClick event the form shall be closed and another form shall be shown with the option to have access to AutoCAD. That's not good. It is even very bad - especially for having access to AutoCAD. Because you try to get access to AutoCAD while still a OnClick-event from the initial form is still running! Although you don't expect this and you think the OnClick event of the initial form is already over. That's why the entmod line didn't work and I changed it to do it via ActiveX to make it work.
The reason is the modeless form the subform is starting from. It would be easier to make it work from a modal form but I'm afraid that this is a part of a bigger project and you try to start it from a modeless form/palette/dockable form.
So, to solve this, it would need another reconstruction: the subform should be started from a asynchronous called command using dcl_sendstring.
Quote from: andrew on February 18, 2010, 06:03:07 AM
(dcl_Form_Close STKBK_stockbook 3)
what does the 3 mean
1 and 2 is explained in the helps but i didnt see 3
That's right. You cannot see 3 in the help because 3 was my own choice ;) . These values mentioned in the help are reserved values. That means, you can use your own values greater than 2 for additional reasons.
Quote from: andrew on February 18, 2010, 06:03:07 AM
if i were to change the 3 to a 1 would that exit me out of the while loop when i press enter?
No, that are two different things. I also noticed that the form is being closed after pressing ENTER.
Have a look at the FAQ (http://www.opendcl.com/forum/index.php?topic=1061.0) to solve that.
The value passing dcl_form_close is the returning value given by dcl_form_show to evaluate later.
Quote from: andrew on February 18, 2010, 06:03:07 AM
if i were to change the 3 to a 1 would that exit me out of the while loop when i press enter?
You are right! I must agree with you that Copy&Paste did a better job in the past! Have a look in your code. There you can read
(defun c:dwgbrowser_stockbook_OnInitialize (/)
(dcl_Control_SetText STKBK_stockbook_TextBox1 "")
); c:dwgbrowser_stockbook_OnInitialize
What do you mean? Wouldn't it work better if you use instead
(defun c:STKBK_stockbook_OnInitialize (/)
(dcl_Control_SetText STKBK_stockbook_TextBox1 "")
); c:STKBK_stockbook_OnInitialize
Just kidding :D I've overseen it, too.
Fred
Quote from: Fred Tomke on February 18, 2010, 07:10:40 AM
So, to solve this, it would need another reconstruction
you are just filled with good news :'(
Quote
You are right! I must agree with you that Copy&Paste did a better job in the past! Have a look in your code. There you can read
(defun c:dwgbrowser_stockbook_OnInitialize (/)
(dcl_Control_SetText STKBK_stockbook_TextBox1 "")
); c:dwgbrowser_stockbook_OnInitialize
What do you mean? Wouldn't it work better if you use instead
(defun c:STKBK_stockbook_OnInitialize (/)
(dcl_Control_SetText STKBK_stockbook_TextBox1 "")
); c:STKBK_stockbook_OnInitialize
Just kidding :D I've overseen it, too.
Fred
wow im blind...
i have a bit more reading to do before i can continue with this project
Fred thank you for your explaination on things
Hi, andrew,
Quoteyou are just filled with good news
That's why I call myself Mr. Bad Guy :P
No, seriously, I thought about changing your project again, but this evening I had a meeting with a friend. And now I have a meeting with my wife. Sorry. But will have a closer look when I find the time in the next days.
Fred
Hi, andrew,
and here it is:
- I've given you two wys to start the subform. Compare EventInvoke property of both the buttons and the event handler names they call in the event tab.
- Please prefer the second way (button).
- I've created a new command for the subform. This command is called by both of the buttons.
- That's why you can repeat this command by pressing enter after closing the subform.
- If the main form is active on screen, it will be set hidden for the time the subform command is running. Don't forget to make it visible after each subform command.
- The list will be filled initially with all the items of the txt file. Then the user can filter it by typing a search string.
- I've added the OnCancelClose event to make sure pressing enter in the textbox will invoke a new search.
- I prefer to see the same when the subform comes up as I left it before. So it's a good design to keep the last search.
- I've added a Clear button to clear the last search.
- When double clicking a listbox item the text objects are changed using entmod instead of ActiveX again.
I hope that I didn't miss anything!
May I use this sample for my FAQ about closing and reshowing forms?
As you can see the way to do this from modal forms is quite different to modeless forms.
Fred
Hi Fred,
WOW you have re-written the code alot heh
i wasnt expecting that, but thanks.
im still reading over the links you posted
to get a better understanding of how this works.
this code is or was however a subroutine of a larger code
which was broken down to its own for the purpose of debugging
the main code which this routine will be called from is a modeless form
so i guess this will work?
after i ran your code i get an error
NIL value not allowed
function: dcl_control_setvisible
argument: 0
when i click "ok" the program starts up
please feel free to use this for your FAQ im sure there will be some beginner out there who can benifit from this.
thanks
all is good Fred, i restarted acad and its working now
Andrew:
Please don't edit your posts to add a followup comment -- just post a new message instead. I can figure out what happened because I saw your original message before you edited it, but someone reading this thread now will be confused by your statement at the end "all is good..." after you just described a problem.
ok sorry
i will do that from now on
thanks