digitalcarbon Posted April 2, 2010 Share Posted April 2, 2010 need to select the same field in many records. please see attached Quote Link to comment
Pat Stanford Posted April 2, 2010 Share Posted April 2, 2010 No great suggestions, but some questions and ideas. 1. If all the record formats have the same fields, why do you need to use different record formats? Could you edit the objects to use a single record and just adjust the fields as necessary? 2. Do you have a different way to select the objects you want to change other than by the data in the multiple records? If so, it will be much easier. 3. If you can select them, just put in a loop and step through each object get a handle to the attached record and then change the field. 4. If you can't select them, the best option would be to learn about List Browsers in the Modern Dialog and create a list of all the record formats and do a multiple selection of the record formats you want to change. Then loop through each of the record formats in the list and use ForEachObject to do the actual change to the objects. Write back if you need more help/information. Quote Link to comment
MullinRJ Posted April 3, 2010 Share Posted April 3, 2010 Digi'M, ???You are almost there with your VW generated script. Unfortunately, VW does not take it to the next step, which is to set up a loop to check multiple conditions. For that, you have to do a little scripting yourself. ???Luckily for you, I have one here. The trick that makes this work is knowing how to pass a <criteria> expression to one of the VS calls that require it for input. ???This is the part that is not easily found in the documentation: VAR CRITERIA :STRING; and you can build your own string and pass the result to a waiting VS command for further processing. If the string is malformed it may compile but you will either get a runtime error or no action at all. ???In your case I built the string from 3 pieces and glued them together with the concat() function. The first and third pieces are static text, while the middle part is the number you want to insert as a wildcard. PART 1) eotroads_ PART 2) #???( a number from 1 to 999 ) PART 3) Rec.Class = 5 ???When assembled, it will look like this (when # = 12): eotroads_12Rec.Class = 5 PROCEDURE SelectByRec; { Select objects that match the criterion "eotroads_###.Class = 5", } { where ### = 1 to 999. } VAR I :Integer; S :String; BEGIN DSelectAll; for I := 1 to 999 do begin S := concat('eotroads_', I, 'Rec.Class = 5'); { criterion in string form } SelectObj(S); end; END; Run(SelectByRec); ???I'm not sure what you are doing, but Pat's first comment might make your life easier, if you can change your record strategy. Tell us more about what you are doing and someone out here mighgt have some good ideas on how to use the software better. HTH, Raymond Quote Link to comment
MarcelP102 Posted September 27, 2022 Share Posted September 27, 2022 (edited) Hi, So you can only use wildcards (*) for criteria fields? This works to select objects using 'voetpad' and 'voetgangersgebied' record SelectObj(INSYMBOL & INVIEWPORT & ('ESRI_BGT - wegdeel'.'functie'='*voet*')); But using ForEachObject and then the PROCEDURE using this code does not work? IF GetRField(h,'ESRI_BGT - wegdeel','functie') = '*voet*' THEN SetClass( h, '94 terreinafwerkingen-verharding-trottoir' ); Is this a limitation of Vectorscript? It would make scripts like this one below much cleaner, I simply use ='*rijbaan* { klasse verharding - rijbaan } IF(selType='inrit') OR(selType='rijbaan autosnelweg') OR(selType='rijbaan autoweg') OR(selType='rijbaan regionale weg') OR(selType='rijbaan lokale weg') OR(selType='rijbaan regionale weg: verkeersdrempel') OR(selType='rijbaan lokale weg: verkeersdrempel') OR(selType='rijbaan autosnelweg: verbindingsweg') OR(selType='rijbaan autoweg: verbindingsweg') OR(selType='rijbaan regionale weg: verbindingsweg') OR(selType='rijbaan autosnelweg: calamiteitendoorsteek') OR(selType='rijbaan autoweg: calamiteitendoorsteek') OR(selType='overweg') OR(selType='OV-baan') THEN SetClassN( h, '94 terreinafwerkingen-verharding-rijbaan', TRUE ); Edited September 27, 2022 by MarcelP102 Quote Link to comment
MullinRJ Posted September 27, 2022 Share Posted September 27, 2022 1 hour ago, MarcelP102 said: But using ForEachObject and then the PROCEDURE using this code does not work? IF GetRField(h,'ESRI_BGT - wegdeel','functie') = '*voet*' THEN SetClass( h, '94 terreinafwerkingen-verharding-trottoir' ); @MarcelP102, Try this instead. IF (Pos( 'voet', GetRField(h, 'ESRI_BGT - wegdeel', 'functie' )) > 0) THEN SetClass( h, '94 terreinafwerkingen-verharding-trottoir' ); For any occurrence of a substring IN a target_string - (eg. - '*voet*'): POS (substring, target_string) > 0 For any occurrence of a substring at the BEGINNING of a target_string - (eg. - 'voet*'): POS (substring, target_string) = 1 For any occurrence of a substring at the END of a target_string - (eg. - '*voet'): POS (substring, target_string) = (len(target_string) - len(substring) + 1 ) In the last example, make sure the length of the target string is equal to, or longer than, the substring or you could get some false positives. Raymond 2 Quote Link to comment
Sam Jones Posted September 27, 2022 Share Posted September 27, 2022 "calamiteitendoorsteek" "terreinafwerkingen" Medium size words Why Germans don't play Scrabble. Quote Link to comment
MarcelP102 Posted October 2, 2022 Share Posted October 2, 2022 Thanks @MullinRJ got it working. So cool to see the drawing being made in seconds by script instead of hours by hand🤩 Quote Link to comment
MullinRJ Posted October 3, 2022 Share Posted October 3, 2022 16 hours ago, MarcelP102 said: So cool to see the drawing being made in seconds by script instead of hours by hand🤩 That is an incredible feeling, I agree. Glad to help. Raymond 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.