Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 Doom9's Forum New Script: FindStrClass
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 24th August 2011, 11:24 #1  |  Link jmac698 Registered User   Join Date: Jan 2006 Posts: 1,862 New Script: FindStrClass This is like FindStr but finds a class of character, like the first number, letter, symbol or specially defined character. Code: ```#FindStrClass Ver 0.9 by jmac698 #A Script Function to find the next number, letter, symbol, etc. s="x 0" r1=FindStrClass(s,4,"") r2=FindStrClass(s,2,"") r3=FindStrClass(s,3,"") msg="With '"+s+"' the first letter at "+string(r1)+" first number at "+string(r2)+" first symbol or number at "+string(r3) return messageclip(msg) function FindStrClass(string base, int classmask, string special){ #Return position of specified character class #symbol=1, number=2, letter=4, special=8, null=0 #these can be combined for classmask, #e.g. maskclass=14 is special or letter or number FindStrClass2(base, classmask, special, 1) } function FindStrClass2(string base, int classmask, string special, int currpos){ substr=midstr(base,currpos,1) t=binbool(strClassify(substr, special),classmask,"and")!=0 || currpos==strlen(base)+1 t ? currpos : \ FindStrClass2(base, classmask, special, currpos+1) } function binbool(int a, int b, string op){ #Find the binary AND or OR on a and b op=lcase(op) op=op=="or"?"||" : \ op=="and"?"&&" : \ strlen(op)==1?op+op:op binbool2(a, b, op, 0) } function binbool2(int a, int b, string op, int currresult){ m=max(a,b) pwr2=int(pow(2,floor(log(m)/log(2)))) bit_a=floor(a/pwr2) bit_b=floor(b/pwr2) t=eval(string(bool(bit_a))+op+string(bool(bit_b)))?pwr2:0 currresult=currresult+t a=a-bit_a*pwr2 b=b-bit_b*pwr2 a+b==0?currresult:binbool2(a, b, op, currresult) } function bool(int n){ #Return false if n=0, true otherwise n==0?false:true } function strClassify(string s, string special){ #Classify a character as symbol (1), number (2), letter (4), special (8) or null (0) s=leftstr(s,1) s=="" ? 0 : \ s==special ? 8 : \ (s>="a" && s<="z") || (s>="A" && s<="Z") ? 4 : \ s>="0" && s<="9" ? 2 : \ 1 }```
 24th August 2011, 22:22 #2  |  Link TheFluff Excessively jovial fellow   Join Date: Jun 2004 Location: rude Posts: 1,049 Why is this thread and the binary maths one in the Avisynth development forum?
 24th August 2011, 23:59 #3  |  Link jmac698 Registered User   Join Date: Jan 2006 Posts: 1,862 Because it's about plugin and script development? It's certainly not about usage. This is the programmers forum isn't it?
25th August 2011, 10:13   #4  |  Link
TheFluff
Excessively jovial fellow

Join Date: Jun 2004
Location: rude
Posts: 1,049
Quote:
 Originally Posted by jmac698 Because it's about plugin and script development? It's certainly not about usage. This is the programmers forum isn't it?
Your scripting is Avisynth usage; it's not development of either a plugin or the Avisynth core. Therefore it goes in the Avisynth usage forum, IMO. Furthermore I'd say you should keep all of your small utils in one thread since you seem to be posting new ones every week and most of them aren't getting very many comments.

 25th August 2011, 19:57 #5  |  Link jmac698 Registered User   Join Date: Jan 2006 Posts: 1,862 That's a great idea, I should make a jmac_utils package and keep adding to it. There is something similar in the jd_utils. I find posting publicly useful for me as I find my own work easier on the web than my own harddrive I've also made some major scripts like vcr simulator or glitch analyzer, these are not in the same vein as short util functions. It's up the mods to move it, not sure I have power to do this unless I delete everything and repost, but the comments would still be there? I don't think users can delete an entire thread.
25th August 2011, 22:49   #6  |  Link
TheFluff
Excessively jovial fellow

Join Date: Jun 2004
Location: rude
Posts: 1,049
Quote:
 Originally Posted by jmac698 That's a great idea, I should make a jmac_utils package and keep adding to it. There is something similar in the jd_utils. I find posting publicly useful for me as I find my own work easier on the web than my own harddrive I've also made some major scripts like vcr simulator or glitch analyzer, these are not in the same vein as short util functions. It's up the mods to move it, not sure I have power to do this unless I delete everything and repost, but the comments would still be there? I don't think users can delete an entire thread.
Yes, of course bigger/more interesting scripts should have their own threads, but for small utils like these a single thread would be better, IMO.

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements and Chat     General Discussion     News     Forum / Site Suggestions & Help General     Decrypting     Newbies     DVD2AVI / DGIndex     Audio encoding     Subtitles     Linux, Mac OS X, & Co Capturing and Editing Video     Avisynth Usage     Avisynth Development     VapourSynth     Capturing Video     DV     HDTV / DVB / TiVo     NLE - Non Linear Editing     VirtualDub, VDubMod & AviDemux     New and alternative a/v containers Video Encoding     (Auto) Gordian Knot     MPEG-4 ASP     MPEG-4 Encoder GUIs     MPEG-4 AVC / H.264     High Efficiency Video Coding (HEVC)     New and alternative video codecs     MPEG-2 Encoding (HD) DVD, Blu-ray & (S)VCD     One click suites for DVD backup and DVD creation     DVD Rebuilder     (HD) DVD & Blu-ray authoring     Advanced authoring     IFO/VOB Editors     DVD burning Hardware & Software     Software players     Hardware players     PC Hard & Software Programming and Hacking     Development     Translations

All times are GMT +1. The time now is 04:52.

 Doom9.org - Archive - Top