Closing an already added script

Hello!

I am really new in this world of scripting. Got into it because i wanted to learn how to custimize my iPhone.
So this might be a really silly question…

It is regarding the Weather Cal widget script. I want to reset the widget i have done, and in order to do that i have to “close” the script and “reopen” it in order for the change to take effect. What does it mean by that? Ive tryed everything. Closing the app. Deleting the widget, Deleting the script. No matter what i do it does not reset.

How do i close a script?

There are instructions on mzeryck’s GitHub for resetting. Basically just need to run the script in the app and select reset

Sorry, I’ve checked that instruction but it doesent help me.

I am using the widget setup in the Weather cal script in the app. Under “other settings” i can choose to completely reset the widget.

Once i do that, it tells me that the script has been reset. But in order for it to take effect i need to close the script and reopen it. This is where i am stuck. How do i close and reopen it?

Ahh I see now. To close it, you should just need to press the done button or maybe remove the widget from Home Screen, but seems you’ve already done that

Yeah, none of that works im afrain :frowning:

The way it is phrased, it sounds like the code is updating itself, so you need to close and reopen the file when editing it to load the updated code into the Scriptable editor. That would just be tap done, and then tap on the file again.

Looking at the reset code it looks to be deleting files in your library starting “weather-cal-”, (burt not “weather-cal-api-key” or “weather-cal-setup”; and then downloading a fresh copy of the code (from a self reference of https://raw.githubusercontent.com/mzeryck/Weather-Cal/main/weather-cal-code.js).

for (item of this.fm.listContents(this.fm.libraryDirectory())) {
	if (item.startsWith("weather-cal-") && item != "weather-cal-api-key" && item != "weather-cal-setup") {
		this.fm.remove(this.fm.joinPath(this.fm.libraryDirectory(), item))
	}
}
const success = await this.downloadCode(this.name, this.widgetUrl)

Any chance your script file is named something not starting “weather-cal-”?

A simple manual method would be to just copy the code above and paste it over your current script content. That’s the reset. Run it and it should rebuild/redefine your widget.

Im not sure i understand what you mean by copy it and paste it over my current script?

I managed to find the code above in the weather cal code script, and it looks exactly as you posted above.

When i downloaded the weather cal script i got one script for setting up the widget, and one script with the weather cal code. I havent renamed any of them, but i tried to change the name into weather-cal- to see if that made any difference. but it did not.

In what script should i copy and paste the code above?

The one you were trying to reset.

Good - that’s the code that does the reset. It should be the same.

Do note that there was also a link to other code. I can see how this would have been confusing in my previous post, but that is the code that the block of code looks to reference in automatically resetting the widget code. That is what I am suggesting you consider manually copying and pasting.

I would assume that it is the widget code you are resetting. Note that in the code referenced above it is looking for a startsWith, so it isn’t resetting only something with that name, but anything starting with that in the name other than the API key and setup variations referenced.

Judging from what the code is attempting to do it would be to replace your widget code with the code in https://raw.githubusercontent.com/mzeryck/Weather-Cal/main/weather-cal-code.js. Based on that, I would take a backup copy of the widget code (copy and paste it into somewhere outside of Scriptable, or copy the file somewhere outside of Scriptable - so I can copy it back if things don’t pan out) and replace it with the code at that URL.

Then when you run the widget code again you should have reset back to this point in the instructions on GitHub.

I guess another alternative would be to delete the widget file (after backing up) and run the calendar script again. That would effectively be equivalent.

Create a simpel shortcut


Add this shortcut to your scriptable like this


//Setup for Launching ShortCuts in Script

//const SHORTCUTNAME = "Alarm_Set";
const XCBURL =  "shortcuts://x-callback-url/run-shortcut"
let cb = new CallbackURL(XCBURL);
let cb1 = new CallbackURL(XCBURL);

function OpenShortCut(){

cb.addParameter("name", "Set Alarm from list");
cb.open();

cb1.addParameter("name", "Get_Volume");
cb1.open();

}

In the code, I launch 2 Shortcuts… replace “Set Alarm from list” to “RefreshWidgets”
Done.:wink:

In Scriptable… App.Close will close the Scriptable and return to the Homescreen… only it closes too soon for my scripts…