![]() |
#1 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
Normal AVS Code -> loop() code translator
I wrote a little program that I think one of you might be able to use
![]() It takes any (valid) AVS code and transforms it into either - a nicely readable 1 assignment/command per line form, - a not so nicely readable 1 assign()/command per line form - a mix of assign()s and exec3()s which will most likely be unreadable but compatible to loop() ![]() All of these forms are equivalent and as syntactically correct as the input ![]() You can then use the code in the following form: code: You can also use the generated code for if blocks if you want ![]() code: I provided the source (VB6) so you can alter the program to suit your needs or even improve it ![]() Just give me credit if you use it in an AVS ![]() You will need a VB6 runtime DLL (msvbvm60.dll) for this! [edit]You can download it here[/edit] [edit]I removed the OLE automation stuff so you only need msvbvm60.dll now.[/edit] [edit]changed the interface a bit ![]() Last edited by TomyLobo; 17th March 2004 at 09:35. |
![]() |
![]() |
![]() |
#2 |
Forum King
Join Date: May 2003
Location: Fnord?!
Posts: 2,657
|
From the way I read this, it sounds like a good thing... I will see how it works after a little bit of tinkering and report back later.
//added// It works as far as I can tell, no matter what code I throw at it, it works. I could see how this would be useful for some odd ball things, but I personally can't see any use for it right now. Request-Allow for comment ,// */ /*, support. //added// |
![]() |
![]() |
![]() |
#3 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
// and /*...*/ should be no problem... this is treated as a part of the next command or of the next variable of the assignment
it will look a bit strange but it should work i think ![]() code: becomes code: which works, too ![]() code: becomes code: that' also valid, equivalent code I could write something to filter the comments out if you want that. should be no problem ![]() and btw: save your original code, it will be very hard to edit the code my program generates, as it does not structure it at all ![]() I'm going to make it convert something like "loop(1,a=b);" to "loop(1,assign(a,b));" so you can write whole code blocks and then let my program translate them. ![]() ![]() |
![]() |
![]() |
![]() |
#4 |
Forum King
|
Nice idea.. but don't expect credit for making something easier that anyone could do otherwise. Do I credit Paint Shop Pro's authors when I use it to convert a .jpg to a .gif? I'd use this if you let me do so without credit.. otherwise I'd rather do it the long way than mention your name in an AVS comment when you had nothing to do with the actual preset or its code.
It is a really good idea though.. unfortunately I can't see any situation where I'd need to loop and enormous block of code without having a really slow preset. |
![]() |
![]() |
![]() |
#5 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
It's done
![]() You can now check a box to filter comments and you can now write things like code: which is transformed to code: or even cascade the loops code: to get this: code: The indentation is not necessary btw ![]() [edit] jheriko: hmm just mention that you used the program somewhere in the comments, so people know you went the short way, i think that's just fair. ![]() and about the usage... you could actually speed up your presets by using translated conditional blocks like code: and finally you can use big loops in Init or not so big loops in Frame. [/edit] [edit] small bugfix: doesn't crash anymore when entering code with syntax errors ![]() [/edit] Last edited by TomyLobo; 18th March 2004 at 06:49. |
![]() |
![]() |
![]() |
#6 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
bugfix
i fixed a (quite stupid
![]() ![]() |
![]() |
![]() |
![]() |
#7 |
Whacked Moderator
Join Date: Jun 2001
Posts: 2,104
|
It's much easier to just use assign()+assign()+assign()+... rather than nested exec3's and exec2's IMO.
|
![]() |
![]() |
![]() |
#8 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
that's true but it's probably slower
![]() since i wrote this program for loop()s at first i decided to use the exec()s [edit]I'll make a checkbox for that ![]() |
![]() |
![]() |
![]() |
#9 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
sorry for double posting but I forgot to add the new version
![]() another improvement: you can now choose not to translate the first level of commands, allowing you to translate whole preset blocks of this form: code: with the checkbox "Translate first level" unchecked this is translated to: code: [edit]added the new translation mode UnConeD suggested[/edit] Last edited by TomyLobo; 18th March 2004 at 17:28. |
![]() |
![]() |
![]() |
#10 |
Forum King
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,125
|
Sweet stuff here! Really useful!
Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever |
![]() |
![]() |
![]() |
#11 |
Senior Member
|
Very handy. Thanks for making this!
|
![]() |
![]() |
![]() |
#12 |
Senior Member
Join Date: Aug 2002
Location: USA
Posts: 158
|
Very nice! This is an excellent tool that will be used A LOT (at least by me). It's so tricky to write code in nested loops and not have parentheses missing (or too many) that prevent compilation. This solves all of that! You are definitely going to get some credit in the credits of my next pack, because this makes creating code-driven AVS presets much more straightforward. I only wish it would have been out sooner, because I just got done making an extremely complicated preset that used a ton of code and I used plenty of time debugging mistyped code.
EDIT: I just tried converting about 200 lines of code in that preset to exec2/3's (just for fun). It worked perfectly, so I can almost 100% confirm there are no bugs in this program (although my original code had no comments, so that feature is untested by me). Last edited by Shock Value; 19th March 2004 at 01:34. |
![]() |
![]() |
![]() |
#13 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
the comment filter should work flawlessly because it's not that complex
![]() ![]() and it looks for // and deletes everything until the next CR+LF. Erm ok there is one issue with the comment filter: please dont use the string "fgsfoihjoadas" anywhere in the input because it will be replaced by a slash ![]() after all of these constructed mini-examples here's a real example that might give you an idea of what you could do with the program. here's one of my presets i wrote with my tool. It's mainly for testing purposes since it has no beat reaction or own movement ![]() It's a reflective sphere and a plane. the camera can be controlled by the mouse (hold left mouse button down to pan the camera) and the keyboard (cursor keys to move around). the main raytracing code is contained in these 2 nice if()s: ![]() code: The first if() makes sure the sphere is only raytraced if the viewer is not on the wrong side of the plane. The second if() does the reflection calculations only if the sphere is actually hit (anyone got better code for determining this instead of the approximating code? ![]() The non-translated code is provided in the comments after the DM and the Texer II respectively. |
![]() |
![]() |
![]() |
#14 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
forgot the attachment *g*
|
![]() |
![]() |
![]() |
#16 |
Junior Member
Join Date: Jan 2004
Location: berlin, germany
Posts: 44
|
hm, usefull, really!
this programm is very helpfull when using e.g. whittaker iteration (or othe iterations) on raytracing presets. some kind of back-converter that can convert the generated code back mortal winamp code. nochwas: tomy, du kannst doch so gut proggen. bitte schreib mal ein programm welches syntax-fehler im AVS code markiert. fehlersuche in superscopes etc. stress manchmal wirklich, da bei einem fehler einfach garnix gemacht wird. bis gleich! |
![]() |
![]() |
![]() |
#17 |
Forum King
|
Never thought of using code inside ifs like that to optimise stuff so heavily. I suppose containing massive blocks of code inside ifs is a really efficient way of dealing with some things.
|
![]() |
![]() |
![]() |
#18 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
@your-dentist
(he asked me to write an AVS syntax checker) Such a syntax checker is already integrated in AVS. Open Settings/Debug Window... and check the "Log compile errors" checkbox. AVS will then display all erronous code in the "Recent eval code errors" box as soon as you change something in the code in question So nen Syntaxchecker ist schon in AVS integriert. Geh mal auf Settings/Debug Window... und aktivier mal "Log compile errors" Dann zeigt dir AVS sämtlichen fehlerhaften code in der "Recent eval code errors" Box sobald du den fragliche code änderst. |
![]() |
![]() |
![]() |
#19 |
Major Dude
Join Date: Apr 2002
Location: Ballarat, Australia
Posts: 529
|
http://zevensoft.no-ip.com/filedump/avs/codeconvert.exe
Can convert VB6 code into AVS. Atm only supports dim, global, private, for/next, and =. Other statements will be left intact. Example: code: Will create avs code that does the same. Note that you need to enable interlaced arrays for dynamic arrays, as I haven't coded a dynamic memory manager yet. And I cbf coding it either. |
![]() |
![]() |
![]() |
#20 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
Nice idea Zevensoft
I picked out some advantages and disadvantages of using your program instead of mine: advantages: - you don't have to learn the AVS language - you can use (parts of) existing VB6 programs directly in AVS - easy (g)megabuf handling disadvantages: - you have to learn VB6 ![]() - with the easy (g)megabuf handling of your program you don't know what is in your (g)megabuf and where, so you have to write the whole code in VB6 - you have to convert AVS code to VB6 (which your program can't do yet) to use it in your program - you don't work close to the AVS language anymore and it's hard to optimize your program's output. this is also true for my program, but you can optimize before translating as my program doesn't add any extra commands. I tested that: "a=b; c=d;" and "exec2(assign(a,b),assign(c,d));" both generate 37 bytes code - your program always creates assign(...)+assign(...), which is slighty slower than the exec2/3() blocks my program creates (feel free to take the "mkexecs" function from my program to achieve this, it needs to be called until the array of commands has only 1 element left) code: (assumes LBound(outField) = 0) - your program only supports a finite number of flow control operations. For example if Nullsoft decided to implement something like While...Wend from VB6 in AVS, you have to change your program. I don't need to change mine because it accepts assignments inside all functions. you could for example write code: in my program and it would convert it to strange but working AVS code. Bugs(or maybe not yet implemented features? ![]() That code example you supplied is not VB6 but it looks like VB6 VB6 needs ReDims for dynamic arrays and you write MOD instead of % try this for the modulo problem: code: this replaces " mod " (case insensitive) by "%", which should be enough since the VB6 IDE formats the code this way... try to convert code: it won't work... multiple commands in 1 line are sometimes needed in order to preserve clarity btw your program generates an "index out of range" error for this code: code: fix this ![]() Your program doesn't support comments (yet). Try using a modified version of the FilterComments() function in my program if you want. (assume FilterAll = True and remove everything that is not executed with this assumption to leave out all the stuff i use for the Comment Codes) btw there's a new version (1.8.01) on my page and I will put 1.9.00 there, soon, which will support easier megabuf assignments. I'm starting to write this now ![]() [edit] Hmm this was 2 lines of code added. The uploading was the hardest part ![]() [/edit] |
![]() |
![]() |
![]() |
#21 |
Senior Member
Join Date: Aug 2002
Location: USA
Posts: 158
|
I can't seem to get the "Auto Clipboard" feature working, which is a shame because it sounds like a really useful idea. I've tried playing with the checkboxes and the //$DoAutoClipboard comment but copying and pasting code does not run it through your converter no matter what I do.
EDIT: I'm using version 1.9.00. |
![]() |
![]() |
![]() |
#22 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
Hmm it works for me...
I started AVSTrans and activated the "Auto-Clipboard mode" checkbox and copied this into the clipboard: code: and pasted it somewhere else and got code: [edit] the DoAutoClipboard comment needs to be in the clipboard, NOT in the input box [/edit] Auto-Clipboard mode scans the clipboard once in a second, this means that you'll need to wait up to 1 second to get the converted code, so don't paste too fast ![]() Make sure you checked the "Translate first level" checkbox if you use normal AVS code as input (without something like "loop(n,a=b)") Also check the spelling of "//$DoAutoClipboard" and try to put it in the first line (should normally not be necessary but it's worth a try) Another problem might be clipboard managers... I don't have one of them installed so i don't know how they work but they might interfer with the Auto-Clipboard mode of my program. Try to normally convert the code in question using the input box and see if there are errors (normally auto-clipboard mode should do exactly the same as pasting the code into the input box and copying it from the output box, but something might have been messed up, so please try that too ![]() |
![]() |
![]() |
![]() |
#23 |
Senior Member
Join Date: Aug 2002
Location: USA
Posts: 158
|
Oh, OK it works now. I thought the comment code only had to be in the input box for some reason.
|
![]() |
![]() |
![]() |
#24 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
i made the DoAutoClipboard thing to prevent AVSTrans from translating everything in the clipboard: URLs, your documents, pictures
![]() [edit] I updated the CHANGELOG on the website (not in the .zip) and removed some ambiguities regarding the placement of the DoAutoClipboard comment ![]() [/edit] Last edited by TomyLobo; 28th March 2004 at 00:13. |
![]() |
![]() |
![]() |
#25 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
new version
|
![]() |
![]() |
![]() |
#26 |
Forum King
|
i think this is pretty pointless...people should be able to translate their code themselves. also, exec2(,) and exec3(,,) are useless afaik, cos assign(,)+assign(,)+assign(,) ... does the same thing without the extra computation of another function.
"guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
![]() |
![]() |
![]() |
#27 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
the AVS evaluator compiles your code to machine code and stores it for execution
knowing that, it should be clear that it's actually the other way round: that + sign generates an ADD instruction, while the execs are just another way to write semicolon separated assign()s. they are not "calculated" you can also test it: make a new .avs, add a SSC, write some code in it, look at the Eval code stats in the debug window. it says xxxx+xxx bytes code next, copy your code to AVSTrans and let it translate it into execs. replace the SSC code with these execs and look at the Eval code stats in the debug window again: no change ![]() still the same code length, and thus the same execution speed now try the same with the assign+assign method and you should notice an increase in the code length, which is caused by the ADD instructions i mentioned above. and about translating your code manually: you did probably not read the whole thread as i posted a quite complex example (raytracing with some if blocks to increase speed) try that manually ![]() the code will probably be erronous because you forgot a bracket, comma or the likes somewhere the example is here. |
![]() |
![]() |
![]() |
#28 |
Whacked Moderator
Join Date: Jun 2001
Posts: 2,104
|
Atero, I think I've said this about a hundred times or so: stop nagging about extra function calls or whatever in AVS. And now, you don't have the excuse of not having the source code. Get yourself the 5.02 AVS SDK and take a look at nseel-cfunc.c. Now you know exactly what all that code in AVS does.
Almost all functions now result in direct compiled code without jumps or calls. Only complicated math operations such as the arctrig functions or pow/exp cause actual jumps into external code. |
![]() |
![]() |
![]() |
#29 |
Banned
|
I am confuse. sorry I don't undrastand some parts of it.
|
![]() |
![]() |
![]() |
#30 | |
Forum King
|
Quote:
what computation does + do? is + a function? think about it carefully. i dont even need to look in the source on this one. |
|
![]() |
![]() |
![]() |
#31 |
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353
|
mmmh
+ is a floating point add, which is a few cycles, exec2 is just fetching instructions and putting the last value in the active register, so its practically nothing in cpu cycles. But you would have to do a fair bit of it do notice a difference. |
![]() |
![]() |
![]() |
#32 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
like 20 lines of code in a loop(100)?
![]() If you can't say something nice, say something surrealistic. |
![]() |
![]() |
![]() |
#33 |
Forum King
|
i heard it the first time, christ...x_x
"guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
![]() |
![]() |
![]() |
#34 |
Senior Member
Join Date: Aug 2002
Location: right around the corner
Posts: 223
|
this kicks ass
![]() probably gona save me alot of nervous breakdowns ![]() what about support for stuff like a<b a==b for the ifs? i just hate the damn equal(bla,bla)stuff nah this is a stupid idea i gues cause theat would just make it another language, nm ![]() nice work dood:thubs up: I hate signatures!! *bangs his head on the keyboard in hope of getting an idea* Ufihreevf43n98pevfr |
![]() |
![]() |
![]() |
#35 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
hmm... a<b and a==b and the likes would be quite hard to code. I'd have to parse the whole string for something like == > <
i'd also have to respect precedence (a+b)==(c+d) and a+b==c+d don't have to be the same ![]() atm all functions are treated equally: first, they're split to command name and parameter list commandname(parameterlist) the program looks for commas and keeps track of the bracket level. If it finds a comma and the current bracket level is 0, the string up to the comma is taken as a command block and translated recursively. when the translation returns, the command is composed from the the command name and the translated parameters. If someone has a good parsing/replacement algorithm for the comparisons, i'll put it into the program (provided, i have the permission to do so ![]() Needed is basically something that takes an AVS command block as input and replaces all occurances of some+term-goes*here==another+term-goes*here by equal(some+term-goes*here,another+term-goes*here) The programming language can be VB, VBA, PHP, Perl, C/++, Pascal/Delphi/Kylix, J(ava)Script, VBScript, and maybe even Java ![]() (ordered from best to worst ![]() I also found out that some bugs cause certain combinations of code not to translate to what i intended, namely: code: does not translate correctly code: generates an ERR both result from a simple (and quite stupid ![]() see CHANGELOG.txt for details ![]() |
![]() |
![]() |
![]() |
#36 | |
Major Dude
Join Date: Feb 2003
Location: Somewhere in Canada
Posts: 776
|
Quote:
Darn, I can't think of anything to put here. |
|
![]() |
![]() |
![]() |
#37 |
Member
|
Whooo! Now maybe this'll finally help me understand the whole array thing!
|
![]() |
![]() |
![]() |
#38 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
array thing? you mean (g)megabuf?
it's simple: A (g)megabuf can be seen as a collection of variables (1 million of them ![]() that can be addressed by using an index. Syntax: without AVSTrans: local (only available in this specific component): code: global (shared between the components) local (only available in this specific component): code: with AVSTrans 1.11.00: like the above or: local: code: global: code: note that the above only counts for the newest version (1.11.00) where I fixed that thing i mentioned in the 1.09.00 CHANGELOG entry about those brackets that were needed before 1.11.00. If you can't say something nice, say something surrealistic. |
![]() |
![]() |
![]() |
#39 |
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353
|
i can see myself getting too used to coding with this, then traslating
![]() |
![]() |
![]() |
![]() |
#40 |
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580
|
there is a serious bug in 1.11.00!
everything is fine as long as you dont use the recursing parser (i.e. write things like loop(n,a=b); ) I'm working on a solution just now [edit] The new version (1.11.01) is ready, and is available here The bug mentioned above isn't limited to the recursing parser, but everything should work fine now with the new version. [/edit] If you can't say something nice, say something surrealistic. Last edited by TomyLobo; 14th April 2004 at 06:20. |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|