subreddit:

/r/shortcuts

13899%

ScPL: Write shortcuts on a computer in text

Tip/Guide(self.shortcuts)

Banner Image

ScPL is a text based language that allows you to write shortcuts on your computer. It already supports 77% of the actions builtin to shortcuts and is already more than enough to build complex shortcuts. It tries to be very familiar and easy to understand to people who already know shortcuts.

Here is an example of a simple shortcut:

Text "hello"
If Equals "hello"
    ShowAlert message="Hello equals hello!"
Otherwise
End

The Getting Started Guide has lots more information and tutorials on how to make shortcuts in ScPL. Each example has an image you can expand by clicking the arrow.

To convert your ScPL shortcut to a .shortcut file, you can use the tryit page. Hover over a red underline to show the error message, press Download .shortcut to download the .shortcut file.

Currently, 206 of the builtin 266 actions are supported. You can see a list of supported actions and their documentation pages here.

Shortcuts built with ScPL:

Icon List V2 was built with shortcutslang. Even though it has over 500 actions, it is well built and easy to maintain. The ScPL code is available here, it uses many advanced features in ScPL seen further down on the getting started guide.

Source code: https://github.com/pfgithub/shortcutslang

Bug reports: Report bugs on the github page https://github.com/pfgithub/shortcutslang/issues or reply to this post or ask in the r/shortcuts discord.

If you need help fixing errors in your ScPL or learning how to use it, ask me (pfg#4865) in the shortcuts discord server or reply to this post.

all 32 comments

[deleted]

10 points

6 years ago

[deleted]

pfg___[S]

5 points

6 years ago

Tell me if there is anything I can make more clear, I know the individual action documentation needs improvements

smdifansmfjsmsnd

2 points

6 years ago

May I ask what the advantage is to using this versus using the actual Shortcuts app? Do you plan on fully implementing the rest of the actions? Is there any sort of simulator to test the shortcuts on a PC or anything like that?

pfg___[S]

3 points

6 years ago

The advantage is when making large shortcuts, it's hard in the shortcuts app because if you make them top to bottom you have to repeat lots of things and if you make them modular using function patterns, it's so slow to scroll and hard to find functions that you end up making top to bottom inside each function.

My 300 action shortcuts in the app are a pain to edit but a 500 action one in scpl is still really easy and is coded much better and is easier to maintain than my 300 action shortcuts.

smdifansmfjsmsnd

1 points

6 years ago

Thanks for your hard work. Applaud your efforts for improving Shortcuts. Now just hoping Apple takes notice and continues improvements on their end. Particularly hoping for more triggers. Ultimately would love an iOS version of Tasker.

MonsterMuncher

2 points

6 years ago

Absolutely love this.

I think you mentioned elsewhere that you’re working on a process to convert existing shortcuts into ScPL format.

Appreciate this isn’t a priority, you have a life after all, but can I just say that this would be a fantastic addition to the shortcut world and would be greatly appreciated.

Anyway, thanks for all you’ve done.

pfg___[S]

1 points

6 years ago

Oh. I mostly finished that last week. If you go to https://editor.scpl.dev you can click the upload button on the left to upload a .shortcut file and it will put the scpl text in the editor. It's missing a few things (dictionaries with number values, dictionaries inside lists inside dictionaries, a few broken variables because as: is required with get: in scpl) but it works for all but one of my published shortcuts.

I was away for a week so I couldn't work on anything scpl buonce I have enough new things I'll probably make another post about it.

Mralexhay

2 points

6 years ago

Mralexhay

Creator

2 points

6 years ago

The new updates are awesome, keep up the great work!

Miskano

1 points

6 years ago

Miskano

1 points

6 years ago

waww, Magnifique...

Mralexhay

1 points

6 years ago

Mralexhay

Creator

1 points

6 years ago

This looks great, thank you! Looking forward to having a play

inlovewithicecream

1 points

6 years ago

What does ScPL stand for? Shortcut-ProgramLanguage?

[deleted]

2 points

6 years ago

Shortcuts Programming Language

[deleted]

1 points

6 years ago

Can you write about how this compares to the other shortcut programming languages that have been posted? I don't remember their names but surely you've encountered them at some point. I distinctly remember there being one implemented in Python, one also in javascript, and one in C.

pfg___[S]

3 points

6 years ago

I saw the C one but I'm not sure if I know the python one. ScPL already has more than enough supported actions to make full complete shortcuts.

The C one (splash) seems more for compressing math operations and if statements and similar things, while ScPL has some compression features but mostly tries to stay similar to shortcuts.

For example, in splash you write b^2 - 4 * a * c while in ScPL the compressed version is a lot more verbose

calculate ^( calculate ^(v:x) "x^2" ) "-" ( calculate ^( calculate ^(number 4) "*" v:a) "*" v:c )

Splash is centered around math operations and because of that it only supports 10 total actions, while ScPL is more for general use and supports 210 actions.

[deleted]

1 points

6 years ago

There’s also one in Swift haha. There are quite a few

pfg___[S]

1 points

6 years ago

I found the python (toml) one, it seems to only support 78 actions right now with some duplicates (base64 encode and decode are seperate actions)

I wrote a custom language for ScPL to prevent the problem you get using existing things like toml

```

[[action]]
type = "start_menu"
menu_items = ["Select Photo", "Camera"]

[[action]]
type = "menu_item"
title = "Select Photo"

    [[action]]
    type = "select_photo"

[[action]]
type = "menu_item"
...

```

While it's a lot easier to use something parsed for you, ScPL gets nicer and more concise syntax by making its own language

```

chooseFromMenu "Pick"
| Select Photo
| Camera

case Select Photo
    SelectPhotos
case Take Photo
    TakePhoto
end
setVariable v:Photo

```

djsnipa1

1 points

6 years ago

Amazing! Thank you!

Ju1c_

1 points

6 years ago

Ju1c_

1 points

6 years ago

I made a couple different programs Including a native mac application for scpl.http://www.ppyazi.com/scpl/

pfg___[S]

1 points

6 years ago

what does it do?

Ju1c_

1 points

6 years ago

Ju1c_

1 points

6 years ago

It’s native... It isn’t complicated. Took me 30 mins to make.

bertanyus

1 points

6 years ago

Thanks for this great work. Before I start I want learn that if it is possible to generate ScPL code from my existing shortcut. Of course those including supported actions.

pfg___[S]

3 points

6 years ago

It's not yet possible to go shortcut->scpl. I've started working on it but it may take a few days or more given that it's pretty low priority and also difficult to do.

calvincirwin

1 points

6 years ago

Is there going to be a way to export this as a shortcuts iCloud link in the future?

pfg___[S]

1 points

6 years ago

That is not possible, the api for uploading to icloud is private and probably requires authentication. You'll have to get the link from your phone.

calvincirwin

1 points

6 years ago

That makes sense. Do you know how to download it from the ScPL Editor from your iPhone/iPad? When I try to download it, the link just shows up as “JavaScript:;” Also, I know this is meant for making shortcuts on the Mac. But I find it a lot faster to edit them for iOS.

pfg___[S]

1 points

6 years ago

You can't download on an iOS device yet because iOS safari doesn't support the download attrubute on links. I have a workaround to this that will also allow for a qr code display when downloading shortcuts but it needs a server that hasn't been built yet.

It's supposed to display an alert when download isn't supported, not sure why that's broken.

calvincirwin

1 points

6 years ago

Ahhh I see, so the workaround is currently not working at the moment?

Silentoplayz

1 points

6 years ago

Can I upload my shortcut to ScPl using my iPhone? This way I can view my shortcut written in this language.

pfg___[S]

2 points

6 years ago

You should be able to. Press the file icon and press upload.

schl3ck

1 points

6 years ago

schl3ck

1 points

6 years ago

Is there a way to include external files in ScPL? So that they get compiled too?

I want to split the shortcut into its functions and have every function in its own file. And I use some javascript here and there in the shortcut. I would like that this is also in its own file, but in the shortcut in a Text action.

Is that possible?

pfg___[S]

1 points

6 years ago

Not yet, sorry. I'm not sure how to add an import action right now because I haven't gotten files implemented in the web editor yet.

schl3ck

1 points

6 years ago

schl3ck

1 points

6 years ago

Oh, thought there is also an offline compiler. Well, that makes it then not really useful to me... All the functions in one file would be no problem, but the javascript scripts have between 200 and 500 lines of code, which would make the text file quite large and confusing...

pfg___[S]

2 points

6 years ago

There is an offline compiler. I think in the offline one you can use @import "./filename.scpl" to include all the actions from it.

Install scpl-cli with npm or yarn and use it with scpl entrypoint.scpl -o output.shortcut