sle7en7 Posted October 6, 2014 Share Posted October 6, 2014 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? Quote Link to comment
Hippocode Posted October 6, 2014 Share Posted October 6, 2014 There is an array sort function in vectorscript. It can also be used on structures. Quote Link to comment
sle7en7 Posted October 6, 2014 Author Share Posted October 6, 2014 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. Quote Link to comment
Pat Stanford Posted October 6, 2014 Share Posted October 6, 2014 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. Quote Link to comment
sle7en7 Posted October 6, 2014 Author Share Posted October 6, 2014 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. Quote Link to comment
Hippocode Posted October 6, 2014 Share Posted October 6, 2014 chr(number) turns asci into characters. If you look up "A" or"a" you can to set a loop a-z in order. Quote Link to comment
sle7en7 Posted October 6, 2014 Author Share Posted October 6, 2014 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. Quote Link to comment
Pat Stanford Posted October 6, 2014 Share Posted October 6, 2014 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? Quote Link to comment
sle7en7 Posted October 6, 2014 Author Share Posted October 6, 2014 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. Quote Link to comment
Pat Stanford Posted October 6, 2014 Share Posted October 6, 2014 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. Quote Link to comment
sle7en7 Posted October 7, 2014 Author Share Posted October 7, 2014 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. 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.