XML file will not load

Oops! Shared.

Thanks. I'm not quite sure what is going on, but there have been reports of similar problems. @jens or @bromagosa might be able to help, though .

This is the first time I've seen this sort of problem. @jens, any idea what's going on here?

I'm attaching the project XML, and a screenshot of the errors shown in the console:

imatge

Card Game Beta.zip (130.7 KB)

hmmm, looks like a watcher with a nil value was somehow saved. Lemme check...

Uh-oh, the XML is broken. How was this file saved? Was IE involved?

Oh, it's also using a string library with tons of JS functions...

Okay, I can recover it. But even afterwards the XML remains broken. Let me look some more into this...

Lots happened while I was sleeping? :slightly_smiling_face:

I use Chrome on Windows 10. I do have the string library loaded, although I don’t make extensive use of it. I had a really hairy ask within an ask construct in one procedure. That’s my main suspect. When I recoded that part I used simpler code.

yeah, don't worry, we'll get it to work :wink:

yep, I can confirm that the culprit for the broken XML is the string library. I shouldn't have pulled it, sorry. Just curious: Can you tell me what you need the string library for? Would you be able to manage without it? I'm planning to remove it, like ... now ... to prevent other projects from breaking.

One use was to return the base name of a clone. For instance, I needed just “clone” rather than “clone(2)” in a sensing operation. All uses were in short functions classed as sensing. I may have avoided that when I recoded by getting the parent of a clone and then getting that object’s name.

I’ll test carefully when I pick up the project again later today. I should be able to remove that library now that I know a bit more about Snap! . Although I am an experienced programmer, I am a Snap! novice. I gravitate toward list processing and OOP, and operating on strings is just something I expect to do.

Nah, let me look some more into this. I think we can get it all to work, including the string library. I might either make a quick patch or make the recovered project available to you, then things should be fine again.
The main problem is the presence of several stage watchers for a no longer existing global variable named "Card". When I remove these obsolete watchers your project loads just fine. I'm puzzled by how more than one watcher for that variable was produced in the first place, especially with that variable no longer being present.

Just an idea: Did you perhaps use the "rename all" feature to rename several other global variables each into "Card"?

In the version I produced after the problem yesterday I finally managed to get rid of Card entirely, moving it into a script variable.
I have been striving to improve scope issues. Since I am developing I have a lot of watchers. I periodically remove them all and create a new set when debugging. I must have had a bunch present when I saved that were leftover from my latest debug session.

lots of watchers are what they're meant for :slight_smile: The part that I can't reproduce (and that poses the problems) is how more than one watcher named "Card" ended up onstage (that shouldn't be possible), and how even after you "got rid of the Card variable" that watcher wasn't automatically removed (that should also not be possible).

When I was working (now retired) I seemed to excel at stumbling into edge cases when testing code. So be warned.
I had an object Hearts that used Card as a global. Much later I duplicated that object and renamed it to Spades (then just edited the costumes and renamed one or two other things). But both used Card.
Now I use a script variable myCard, so the two don’t get tangled. My clones don’t need to communicate with each other, but they do need to sense things about whatever is being touched.

Haha, testers that stumble into edge cases are good to have!

Here's your recovered project:
_Card Game Beta (recovered).xml.zip (130.9 KB)
I've also managed to fix the string library blocks so the XML parses again.

Since I can't reproduce how this project got into the problematic state I'll not push any patch and leave it at that. Please let me know if you run into this (or other) issues (again).

Thank you! I appreciate being able to keep the string library. BTW, I think you know my husband Glen Bull from other forum posts.

@Jens @GinaBull Thanks for the assistance with the string library. ... By way of background, Gina’s first degree was in history of art. She worked for several years as a librarian in the Fiske-Kimball Fine Arts Library at the University of Virginia. Inspired by our work with Logo in the late 1970’s, she returned for a graduate degree in computer science. (We jointly published the National Logo Exchange with Tom Lough and Steve Tipps throughout the 1980’s.)

After a career as a computer systems engineer and Unix administrator, Gina retired several years ago. While she has just begun to explore Snap!, like many others, Logo was her first language.

We appreciate everything that you & BH have done to inspire us through development of Snap!

Ah, indeed I do. Great to have both of you here at Snap!