Jump to content

MullinRJ

Member
  • Posts

    1,994
  • Joined

  • Last visited

Everything posted by MullinRJ

  1. 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);
  2. Thanks for sharing. I have some trees in Texas I'd love to know more about, but can't find any pictures anywhere that match. Even people in local nurseries are stymied. I hope this site grows fast. Raymond
  3. Michael, ???In Maarten's example, variable "a" is the ITEM number of the dialog item that was clicked on, or typed in. Every dialog event passes the relevant item number to a "Dialog_Handler" routine. If you want to do something for an event, then you need to have that item number enumerated in the CASE statement in the dialog handler routine with some code to be executed. ???Variable "b" in Maarten's example is "DATA". For the most part DATA is not used by the user. I have only found one instance in 10 years where I've used it and am waiting patiently for another. I'm not holding my breath. ???The formal declaration of the event handler procedure should look something like this: PROCEDURE Dialog_Handler(ITEM :Longint; DATA :LONGINT); ???This procedure is called from the "RunLayoutDialog()" command. Its declaration is defined in the VS Function Reference. "RunLayoutDialog" is a function that starts a dialog then returns the result of the dialog in an integer when the dialog closes ? 1 for OK and 2 for CANCEL. ???The name of the event loop, in this case "Dialog_Handler", is passed in the second parameter of "RunLayoutDialog()". Though the example cited above is a bit cryptic at first glance, a simpler example of this call would be: Result := RunLayoutDialog (dialogID, Dialog_Handler); ???While a dialog is running, the Modern Dialog machinery passes the item number of every item that is invoked to the callback procedure, which again in this case is "Dialog_Handler". The parameter list of "Dialog_Handler" is understood to be two Longints, ITEM and DATA, and does not get spelled out in your code. HTH, Raymond
  4. It's more than theory. I do this for a special case in Reshaper; open a second dialog from inside a first dialog. It may not be the best interface design, but it may work for some instances. The dialogID allows you to have the same item numbers in multiple dialogs. If this were not the case, confusion would ensue if you tried to modify an item number that existed in multiple dialogs. The idea of the dialogID acting as a HANDLE to the dialog window is exactly the right way to think of it. It's assigned at runtime when the dialog opens, and disappears when the dialog closes. Raymond
  5. Usually, you can pass an INTEGER where a LONGINT is required. Often, you can do the reverse, but the result can be garbage.
  6. I should read prior posts more closely before responding.
  7. Who, ???If you've ever read any of my posts, you have seen I use indenting all the time. Is this what you're looking for? for i := 4 to 6 do ??begin ????CreateThreeStateCheckBox (DialogID, i, Concat (' ', i)); ????SetBelowItem (DialogID, i - 1, i, 0, 0); ??end; for i := LayerCount -1 downto 1 do ??begin ????h := NextLayer (h); ????LayerName := GetLName (h); ??end; ???As you've noticed, the TechBoard removes leading white spaces (Sp & Tb), and compresses multiple white spaces in the middle of lines to a single space character. ???The character you want to enter is Non-Breaking-Space (NBSP). On the MAC, use Option-Space. On Windows, try Alt+0160 or Alt+255 (on numeric keypad). The Windows info comes from Wikipedia, and I haven't tried it. Please, only do this for short code segments you want to post inline. For longer code blocks that other people might want to copy, preserve your tabbed formatting with the [/code ] headers. Otherwise, people will have to convert your NBSP characters to Tabs, and that's a pain. ???As for using [kode] [/kode] (misspelled intentionally to prevent it from working), you need to place your CODE between the ] [ characters. [b][kode] Your Code Here [/kode][/b] It will keep its formatting and be placed in a nice little gray box as seen in Pat's post. Raymond
  8. Nearly 2 years ago I posted a PDF of an annotated VW Pref Constants to the Techboard. It's not a complete listing of all preferences, but it has all of the VW prefs that you can set from the VW Preferences Dialog. Document Prefs and Unified View Prefs windows can be found in the second posting in the following thread. Of course, some new settings may have been added since then, but not too many have been. You can find the PDF files here: VW Preference Constants HTH, Raymond
  9. The Use Layer Color pref constant is 11. A list of constants can be found in the VectorScript Function Reference Appendix. The following one line script can be used to toggle the Use Layer Color preference: SetPref(11, not GetPref(11)); Raymond
  10. I was surprised last week when I opened an old file for someone and found that VW 2012 opens files all the way back to MC 7 format. I'm sure NV has mentioned this at some point, but I think they should mention it again and say it a little louder and more often. This gives the software quite a bit of flexibility that it did not have before. As for saving VW files, VW 2012 will save back to VW 12 format. Raymond
  11. You can also save a file as a template using the menu File>Save As Template... It will be saved in your User folder. I have created several templates for starting new documents where I set the Font, Units, Page Scale, Dimensions, and Script Palette. The big distinction for me is the Units (mm, microns or inches). Obviously, your needs will differ from mine, but the concept is the same. You can also add record formats, spreadsheets, layers, viewports, symbols and other resources you use all the time. For resources you use sometimes, save them in a library file. HTH, Raymond
  12. Chris, ???Would you please post your website? I tried "www.AR-works.com", but that's not it. Arlene Best probably doesn't mind, though. Thanks, Raymond
  13. I tried the script on a small file and it did not crash. Perhaps it has to do with a specific object in your file. In a copy of your file, you might try removing symbols to try and locate the offending object. If it still crashes with an empty symbol folder then it is something else. Write back with more info and hopefully someone will be able to help further. Please, work in a COPY of your file. Raymond
  14. Hi Pat, ???Your script will only work on the first layer. NextObj() will return NIL at the end of the first layer and will not return a handle to the first object on the second layer. Of course, if your file only HAS one layer, it works perfectly. ???You could encase your loop inside a loop that steps through the layers and use FActLayer instead of FObject (been there, done that), but I'd suggest using ForEachObject() or ForEachObjectInLayer() which will step through every object in the drawing. Using the GROUP or DEEP options in the latter call will remove the need for recursion. ???This example is definitely not as sexy as your example, but it's fast and thorough; and like your example, it's untested, so caveat emptor and always wear your galoshes when it's raining. Procedure UnlockAll; function Unlock(ObjHandle: Handle) :Boolean; Begin SetObjectVariableBoolean(ObjHandle, 700, False); End; { Unlock } BEGIN ForEachObjectInLayer(Unlock, 0, 1, 1); { All Objects, All Layers, Enter Groups } END; Run(UnlockAll); Raymond
  15. I don't think that is a feature that has an On/Off preference. If you are in the act of selecting objects, the screen will scroll when you get close to the edge. If your mouse button is not down, or you haven't clicked to start selecting, the screen shouldn't scroll when you get close to the edge with the pointer. Are you seeing differently? Raymond
  16. James, Change: ???Procedure RotTest(h : HANDLE); To: ???Function RotTest(h : HANDLE) :Boolean; All of the ForEachObj... VS calls take a FUNCTION as the callback "procedure" except ForEachObject(), which takes a PROCEDURE as the callback "procedure". If you want to terminate the loop early, then the callback "function" needs to return a TRUE value. By default, it will return a value of FALSE, even if it's not explicitly stated, and continue to the end. As to whether your callback will do what you want, I don't know. Raymond
  17. Can you set your screen resolution to a larger value? If the palettes are off screen, this is one way to get access to them. Or, try hooking up to a larger monitor (variation of same trick). Move them back to where you can find them and quit VW. Their positions will be saved in your current workspace and used the next time you run. If you use a laptop and large screen alternately, you should duplicate your current Workspace and set the palette positions for each environment accordingly - Laptop WS and Desktop WS. Use your Laptop Workspace for small screen work and your Desktop Workspace for large screen work. Keep everything else the same. Good luck on your exam. After your exam, please create a signature so our answers can be better directed to your specific needs. HTH, Raymond
  18. MullinRJ

    Drawing Symbols

    hermann, Yes, 2D objects will show in 3D views. You have 2 options, use a Hybrid Symbol or a Plug-In Object (PIO). A symbol is the easier way. A PIO is more flexible, but requires a bit more programming. As you have found, 2D only symbols will show in both 2D and 3D. Only when a symbol has both 2D & 3D parts (Hybrid Symbol) will it show one or the other as the view changes. You shouldn't have to place this symbol inside a PIO to get the behavior you described. It should work just by placing it in the drawing. Remember though, 2D objects that are created on the Layer Plane are really 3D objects and will show in 2D and 3D views. You will need to make sure your 2D objects are Screen Plane objects if you wish them to vanish in 3D views. If you want to show a 2D part without a 3D part, you can put a 3D Locus in your Symbol, place it in a "HideMe" class and hide that class. This will create the 3D side of your hybrid symbol and keep it invisible. ???Locus3D(x, y, 0); ???SetClass(LNewObject, 'HideMe'); ???HideClass('HideMe'); To keep the selection handles consistent in 2D & 3D views, place the Locus inside the Symbol's 2D boundary. Even when the 3D part is hidden, it will still show a selection handle when it is selected. Raymond
  19. This appears to be a bug. I tried preallocating the Dynarray to a value larger than one you needed, but your assignment still brings the allocation back to 13. Not good. PROCEDURE TestString; CONST LargeNumber = 32767; { max 32767 } VAR shortstring : STRING; aString : DYNARRAY OF CHAR; PROCEDURE ChgText(VAR varString: DYNARRAY OF CHAR); BEGIN varString := 'The string has been modified'; END; BEGIN Allocate aString [1 .. LargeNumber]; aString := 'Only 13 chars'; ChgText(aString); shortstring := aString; Message(shortstring ); END; run(TestString); Raymond
  20. Actually, it's not that odd. Polygons are really a degenerate case of Polylines. Remove all the curvy parts, show all the sides, and you've got a Polygon. Since a Line has no curvy parts, it defaults to becoming a Polygon when converted. You can create a Polyline with only Corner Points, but you have to be careful you don't cajole VW into "downgrading" it for you. The method I outlined above is the only way I know of to create a 2-vertex Polyline via VS. There may be others, but I usually stop looking after I find the first way that works. I agree with you that VS is a function-rich language, but I don't think of the language as feature poor, but rather the compiler. VS is not a fully implemented version of Pascal, allocating memory for structures like Linked Lists is missing, and a few other features, but as a whole, it is still very powerful. Of course, there's always the SDK, but you have to get really dirty to develop there. For "quick and easy", it's VS. OK, that last line can be taken with a grain of salt, but there really are a lot of quick and easy uses for VS. Reusable code is not that hard to generate, but it all hinges on the discipline and experience of the programmer. VW does not really facilitate the programming side of things and it is up to the individual to ferret out the details. That said, I have gotten excellent support when needed from the people at NV. Vlado, for one, has been invaluable and enlightening in really tough situations. If you want to get more out of VW through "scripting", stay connected to like minded people. Welcome to the mix, Raymond
  21. The VectorScript Message window is just a place that scripts can write messages for you to read. Sometimes, the script will close the Message window, sometimes not. You may close it at any time. As to the contents of that particular message, it is only relative to the task you were doing at the time it appeared. If it were a more serious message / warning / error, it probably would have appeared in an Alert Dialogue. Someone else will have to help you with your title block problem. Raymond
  22. Well I guess I'm never going to take any of your courses :-P Raymond (Tongue in cheek, all the way)
  23. I've noticed if you are in the Screen Plane drawing mode and you set the Working Plane with the WP Tool then select a 2D tool, the active plane jumps back to Screen Plane. If you were in Layer Plane mode before using the WP Tool, you'll stay in Working Plane mode when you select a 2D tool. To get things right, check the Active Plane menu at the top of the screen after you select your first 2D tool and make sure you are in Working Plane mode. The next time you switch tools you should stay in the WP mode. If you set the drawing plane back to Screen Plane, even if you have a Working Plane set, you'll have to manually set the menu back to WP again to continue drawing on the WP. OR, if you already have a planar 2D object drawn on a WP, then double click on it to activate that WP. Raymond
  24. You're welcome, Ian. If you don't mind adding functions to your code, as in breaking from inline coding, try this one. Calling it will simplify the main loop keeping the hard part of your code more readable and concise. If you don't want or need the handle to the Poly, then you can redefine the function as a procedure. Raymond function TwoPtPoly(P1, P2 :Point; Polygon :Boolean) :Handle; { Create a 2-vertex polygon if Polygon is TRUE, or a 2-vertex polyline if Polygon is FALSE. } { Return a handle to the new object. } Begin BeginPoly; MoveTo(P1.x, P1.y); LineTo(P2.x, P2.y); LineTo(P2.x, P2.y); { Dummy vertex } EndPoly; if Polygon then DelVertex(LNewObj, 3) { Makes it a Polygon } else SetVertexVisibility(LNewObj, 1, FALSE); { Makes it a Polyline } TwoPtPoly := LNewObj; End; { TwoPtPoly } BEGIN OpenPoly; Smooth( 0 ); IF ( objCount < 2 ) THEN AlrtDialog( 'Two or more objects need to be selected' ) ELSE IF ( objCount = 2 ) THEN H1 := TwoPtPoly(P1, P2, True) { TRUE = polygon, FALSE = Polyline } ELSE BEGIN { 3+ objects } BeginPoly; FOR obj := 1 TO objCount DO ... EndPoly; END END;
  25. I guess if I used the right tool it would have been easy. As you say, it's Friday and not all brain cells are on task. VS, to the best of my knowledge (which is obviously limited), does not have a straightforward way to generate 2-vertex Polylines. Even the 2-vertex Polyline that you can draw manually does not export as VS such that you can re-import it and get back to where you started. However, there are usually circuitous paths around most obstacles. I stumbled on this one only moments ago. BeginPoly; ????MoveTo(1, 2); ????Lineto(3, 4); ????Lineto(3, 4);???{ Dummy vertex } EndPoly; SetVertexVisibility(LNewObj, 1, FALSE);???{ Makes it a Polyline } Just duplicate the last vertex and hide a side. You'll end up with one less vertex and no hidden sides ( just as you'd surmise :-p ). If it weren't for guessing, programming VS wouldn't be any fun. If you want a Polygon instead, then delete the third vertex as shown in my previous post instead of using SetVertexVisibility(). HTH, Raymond
×
×
  • Create New...