# Can someone make a difference tool :)

Note this is a request for a tool to highlight differences between different versions of the same Snap! project so that it can help you to find why it doesn't work any more

I'm not expecting Snap! team to make it but it would be a great project for an advanced Snapper to work on!

Reason for this:
I made the classic mistook of "tidying up" my large Mayflower project just before publishing the new version

You'd think after 41 years of coding I'd remembered Rule 1 but no

So, somewhere in the zillions of blocks - something was giving a divide by zero error

But where????

Eventually - I found the offending script where I'd made a mouse slip

but it would have been great to have had a tool that I could have just used to compare old and new versions and highlight the diffs

Is anyone up for the challenge?

Not exactly what you want, but there is a conflict resolution mode and source code is available on GH.

I try the generic XML diff - Compare xml online. After adding a single block I can see

Not a solution but some blocks useful for meta-analysis (@kinestheticlearning )

It dumps scripting area of the sprite as a list:

• sprite name
• XML of the script
• script image as a costume

XML parts can be compared between projects to detect any changes and the image part can be displayed as a hint.

It's implemented as a CodeDB sprite which can be exported after capture and used as input data to the comparator program.

It needs more work to cover custom blocks and to the comparator part. Maybe some joint venture...

I think you can interact with those scripts. (no ring)

You think, you can interact with the costume/image of the script stored in this list? How? At most drag'n'drop as a new costume can be possible. Or copy the XML of the script to clipboard.
Or show the script image with

Oh! You used costumes, not actual scripts!

It may be hard or impossible to follow this workflow, but let's try...

A) CodeDB Project to capture/export data.(JS required)
B) CodeDiff Project to report differences (now requires JS) Project to report/process differences. No JS Version, CodeDiff
Some project variables should be transient but for the demo are persistent.

1. Import CodeDB sprite into every project to be analyzed
2. Run a local script
3. Sprite/data will be exported s CodeDB_????.xml file. Stage size limits the resolution of images.
...
4. Start CodeDiff project
5. Import every CodeDB_???.xml
6. Run script for any 2 sprites
7. Browse non matching scripts with . Zomm ± 30%
G switch "ghost" mode, Shift browse "ghost" side
S search the most similar script, show similarity score
Space cycle, overlap ghost with lef panel to clearly see the differences

If I click on

it doesn't offer to save any xml

Sorry, now should work. Last minut "cleanup".

Working now

Excellent work as always

I took the say block out as it was obscuring the display

Just tried it on my big Mayflower project that I need/wanted if for and it basically works

Seems to find all hat scripts that have changed between 2 versions

And it seems to show the costume of a new sprite introduced between versions

No 1 improvement would be to have the scripts alternate between the two versions (as there are about 10 changes between the versions so it's hard to see what the changes are between each script as it takes 10 key presses to switch between them)

No 2 improvement would be a watcher to say which sprite the script is in

No 3 - some method of zooming the script image as its a bit tricky to see changes in this for example

I wonder if it would be possible to export the images into a side by side giant png image file that could be viewed in external image editor?

I updated project with:

1. "ghost" mode, second semi-transparent sprite controlled with Shift
2. Watcher format current # total ; side (<>)
3. Zoom with

ad.4. Do you know the "File">"Export summary"

To do:

1. Kind of similarity measure (say, based on Levenshtein distance).
2. Use of Multi scene to streamline the process

Added similarity score and finding most similar script (S).
Unfortunatelly new projects require JS, as calculating similarity is quite expensive in pure Snap!

Sorry for not testing and replying

I've been very busy on my Mayflower project adding in hazard detection

As soon as that calms down - I'll give latest version a go

Went to try out latest but getting this error on CodeDiff project

Forgot to share OK now.

I don't seem to be getting anything sensible when using it to compare these two versions of my project

The old version did work for me

Steps I did
Open CodeDB project - export CodeDB sprite
For each project - import CodeDB sprite - run it - save exported XML

Run CodeDiff - import the two xmls from above

Modify

to match with names of my exports

Press space

I'm just getting stuff like this

I saved a project with "diff" of both your projects.
There are 31 differences out of 280 scripts.
I've selected the left part with arrows, when press S (it takes a few seconds on a relatively decent Intel PC). Results are shown in screenshots.

There is a script from "drop down helper" sprite on the left
On the right, other script with similarity score 93%.

It took me a while to see the difference: overlapping the ghost with the left panel, scale up-down.

Variable watchers are awful as user interface, they move with every switch back and forth to "presentation mode" and save. Z order is uncontrollable. Also, the high-resolution stage is barely handled by Snap! but it is required to actually see some details. It helps to zoom out to fit all parts of ide.

You may check your project's CodeDB local "scripts" var, to see if it contains list
[Sprite name, XML, script image].

Changes:
Space cycle, overlap ghost with lef panel to clearly see the differences

That works

Unfortunately, I think it needs to restrict itself to comparing the same named sprite as it's not matching up very well with the correct corresponding sprite between the two projects so giving a lot of false results