michaelk Posted December 26, 2011 Share Posted December 26, 2011 I must be reading right past this in the function reference and not seeing it. There is a CreateEditText() but no SetEditText or GetEditText. And the GetEditText idea can't be right because DialogResult is an integer...(does it have to be?)... confused. Can someone help me out with the correct functions for a dialog box that gets a user string? This is what I expected it to be but with nonexistent functions: Thanks mk Procedure TextDialogQuestion; {Badly scripted by Michael Klaers} VAR DialogID :INTEGER; DialogResult :INTEGER; userString : STRING; PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT); BEGIN CASE item OF SetupDialogC: BEGIN Set[EditText?](DialogID,4,DialogResult); {....what really goes here?} END; 1: BEGIN Get[EditText?](DialogID, 4, DialogResult); {....what really goes here?} userString := DialogResult; END; END; END; BEGIN DialogID := CreateLayout('Get User String', FALSE, 'OK', 'Cancel'); CreateEditText(DialogID,4,'enter text here',24); SetFirstLayoutItem(DialogID, 4); DialogResult := RunLayoutDialog(DialogID, Dialog_Handler); Message('User Entered String is: ',userString); END; RUN(TextDialogQuestion); Quote Link to comment
ccroft Posted December 27, 2011 Share Posted December 27, 2011 Have a look at SetField and GetField. CreateEditText is used to create the field and set the default text that shows in the dialog box... if you want to. Quote Link to comment
michaelk Posted December 27, 2011 Author Share Posted December 27, 2011 (edited) Charles I saw that but got scared off by this: Declaration: PROCEDURE SelField ( fieldID:INTEGER ) ; Special Notes: SelField is obsolete as of Vectorworks 2010 That's the function I want, but I can't find the replacement. mk whoops. Copied the wrong one. I ment to quote this: Declaration: PROCEDURE SetField ( fieldID :INTEGER; str :DYNARRAY[] of CHAR ) ; Special Notes: SetField is obsolete as of Vectorworks 2010 Edited December 27, 2011 by michaelk Quote Link to comment
ccroft Posted December 27, 2011 Share Posted December 27, 2011 I'm still back on 2009 and I think it's mainly for that reason. I'll have to update all my dialogs to Modern Dialog if I ever want to update vWorks. Anyway, I think you'll want GetItemText and SetItemText. Sorry 'bout that. Quote Link to comment
michaelk Posted December 27, 2011 Author Share Posted December 27, 2011 I bet you're right. Now I'll have to learn how to handle a dynamic array! : ) Thanks MK Quote Link to comment
michaelk Posted December 27, 2011 Author Share Posted December 27, 2011 One more question about this dialog box. This is probably me not understanding how a dynamic array of CHRs works.... This script functions (pretty much): [thank you, ccroft] **************************************************************************************************** Procedure TextDialogQuestion; {Badly scripted by Michael Klaers} VAR DialogID :INTEGER; DialogResult :INTEGER; userString : STRING; PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT); BEGIN CASE item OF SetupDialogC: BEGIN SetItemText(DialogID,4,userString); END; 1: BEGIN GetItemText(DialogID, 4, userString); END; END; END; BEGIN DialogID := CreateLayout('Get User String', FALSE, 'OK', 'Cancel'); CreateEditText(DialogID,4,'enter text here',24); SetFirstLayoutItem(DialogID, 4); DialogResult := RunLayoutDialog(DialogID, Dialog_Handler); Message('User Entered String is: ',userString); END; RUN(TextDialogQuestion); **************************************************************************************************** What it doesn't do is put the default string value 'enter text here' into the text dialog box. Any suggestions? I'm trying to pick up an existing value, display it in the dialog box and keep it if the user doesn't change that field. thanks mk Quote Link to comment
MullinRJ Posted December 27, 2011 Share Posted December 27, 2011 Michael, When your program starts, userString is uninitialized. When your dialog starts, the first thing that happens is you write userString into field 4, thus overwriting the starting value of field 4 with a null string. In the code below, I removed that one line in the SetupDialogC section and it runs with your initial text string displayed in the field. HTH, Raymond Procedure TextDialogQuestion; {Badly scripted by Michael Klaers} VAR DialogID :INTEGER; DialogResult :INTEGER; userString : STRING; PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT); BEGIN CASE item OF SetupDialogC: BEGIN END; { SetupDialogC } 1: BEGIN GetItemText(DialogID, 4, userString); END; { 1 } END; { case } END; { Dialog_Handler } BEGIN DialogID := CreateLayout('Get User String', FALSE, 'OK', 'Cancel'); CreateEditText(DialogID, 4, 'enter text here', 24); SetFirstLayoutItem(DialogID, 4); DialogResult := RunLayoutDialog(DialogID, Dialog_Handler); Message('User Entered String is: ', userString); END; RUN(TextDialogQuestion); Quote Link to comment
michaelk Posted December 27, 2011 Author Share Posted December 27, 2011 Thanks! Is there a discussion in any reference of SetupDialogC? Searching the function reference reveals that it is mentioned 17 times, but only in examples of other functions. The language guide lists it 3 times, but always while discussing other topics. It's not a "topic" anywhere I can find. Is there also a SetupDialogA and SetupDialogB? Or does C refer to the language of the SDK? Thanks for your patience, everyone. mk Quote Link to comment
MullinRJ Posted December 28, 2011 Share Posted December 28, 2011 I always thought of the C as standing for "Constant". Statements in this section are executed BEFORE the dialog is presented to the user. Do all of your setup here. There is also a SetdownDialogC. Statements in this section are executed AFTER the dialog is closed by the user. I don't know if you'll ever need SetdownDialogC, but it's there for completeness. Raymond Quote Link to comment
michaelk Posted December 31, 2011 Author Share Posted December 31, 2011 Raymond Where did you find SetdownDialogC? I can't find it in the function reference or the language guide... I'd love to see a discussion of exactly what variables are set and what functions are executed in what order with SetupdialogC and SetdowndialogC. Currently, I'm using the "try this and see if it works" technique... :-) thanks again mk Quote Link to comment
JBenghiat Posted December 31, 2011 Share Posted December 31, 2011 SetUp/DownDialogC are predefined constants. You can think of them like pi -- you can use "pi" in your script, or you can use "3.14159," but using the constant is much easier and clearer. You are right that there is not much documentation. I learned them from a listserve discussion a while ago, which predated even seeing the constant in examples. After a quick search, the only documentation I could find is in the SDK in VectorScript Reference.xml: SUDC: predefined constant value that is passed to the dialog event handler subroutine when a modern custom dialog is initially displayed onscreen.[[bR]][[bR]]This constant is usually used to determine when to execute dialog initialization and setup calls SDDC: predefined constant value that is passed to the dialog event handler subroutine when a modern custom dialog is dismissed.[[bR]][[bR]]This constant is usually used to determine when to execute dialog cleanup calls prior to exiting the dialog If you step through a debugger, you can see these values of the item variable. You could just use those values in your case statement, but using the constants is much clearer. So to directly answer your question -- the variable item (as per the examples) is set to these constants by RunLayoutDialog on the first and last pass through your handler, respectively. No functions get run automaticaly, only what you specify in your handler statement. HTH, Josh Quote Link to comment
MullinRJ Posted January 1, 2012 Share Posted January 1, 2012 Raymond Where did you find SetdownDialogC? Hi Michael, ???To be honest, I guessed. It's one of the few times I took a shot in the dark and hit it on the first try. Saddly, I have never needed SetdownDialogC. I'd love to see a discussion of exactly what variables are set and what functions are executed in what order with SetupdialogC and SetdowndialogC. ???As Joshua said, nothing happens during these dialog events that you don't explicitly program. They are just 2 events that get passed to your handler to start things up and finish them off. No magic involved. If you don't put any code in these sections, the dialog will run as if they never existed. Raymond Quote Link to comment
michaelk Posted January 1, 2012 Author Share Posted January 1, 2012 ???To be honest, I guessed. It's one of the few times I took a shot in the dark and hit it on the first try. Saddly, I have never needed SetdownDialogC. That is an insightful and prescient guess! ???As Joshua said, nothing happens during these dialog events that you don't explicitly program. They are just 2 events that get passed to your handler to start things up and finish them off. No magic involved. If you don't put any code in these sections, the dialog will run as if they never existed. Thanks, Raymond. I'm slowing figuring it out... Until your reply above prompted me to watch the debugger, I was unclear about when SetUpDialogC executed in relation to the rest of the code. It would be nice if there was more documentation. And if the examples didn't involve obsolete functions! thanks! mk Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.