Jump to content
Sign in to follow this  
sle7en7

Set Record Field with Alphabetical Sort

Recommended Posts

I have another request since I can't code even to survive, and hopefully someone has already have one written somewhere but I was not able to find it.

This time, I'm looking for an alphabetical sort script which will set the record field from A to Z on a stacking order basis or some other basis ... idk.

Any ideas, or line of codes?

Share this post


Link to post

Thank you hippo, I know it related with that function but ...

I can't code even to survive
guess I'll have to get into VS and Python a little more.

Share this post


Link to post

What are you actually trying to do? If you want to set a field in a record, especially if you are OK with doing it by stacking order, you don't need a sort function.

I post a script to write data into a record a few days ago. See

https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Main=40740&Number=203171#Post203171

If you can describe what you really need, perhaps I can modify this to do what you want.

Share this post


Link to post

Hi Pat,

You know what I'm trying to do; I'm trying to assign letters to record fields inside a worksheet. So you remember this code right;

Procedure Number_Objects;

{October 1, 2014}
{? 2014, Coviana, Inc - Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

const	MyRec='Test';
	MyField='Seq';

Var		NextNum: Integer;


Procedure MyProc(H2:Handle);
Begin
	SetRField(H2,MyRec,MyField,Num2Str(0,NextNum));
	NextNum:=NextNum+1;
End;

Begin
NextNum:=1;
ForEachObject(MyProc,((R IN [MyRec])));
End;

Run(Number_Objects); 

I'm trying to do the exact same thing but with letters now, if I'm explaining myself clearly.

Share this post


Link to post

I get what you're saying ... I will have to sit down sometime and go over my basic CS skills to put this into practice but I don't have much time these days. Although thank you for the guidance, much appreciated.

Share this post


Link to post

Are you going to have more than 26 objects?

If not, then you can use

SetRField(H2,MyRec,MyField,CHR(64+NextNum);

If you want lowercase use 96+NextNum

If you are going to have more than 26, what should come after Z?

Share this post


Link to post

I think what Hippo said makes sense, so I think "AA" should come after "Z" and loop like that (which I don't know how that will work in code). Same for lowercase. But I'll start playing with the stuff you just provided Pat, thanks a lot.

Share this post


Link to post

You need to decide what the maximum value you are going to handle is before you start trying to write code to convert to base26.

The code will probably be very different if you only need to go to ZZ instead of ZZZ.

You will have to determine each letter separately and then use Concat to put the string together.

Share this post


Link to post

I got you Pat, alright well my maximum value is not more than 26 at this point so I'll go with CHR(64+NextNum). I'll do the "ABC..AABBCC" loop later on, and let you guys know how it goes. Thanks again for the help everyone.

Share this post


Link to post

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...