reserved word or not ?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
reserved word or not ?
Hi All,
To cleaning my app i need to know if word 2 of a message which begin by "on" is s reserved word.
I tried
put ("mouseup" is reserved)
but i'm surprised that it return "false"
Thanks for your lights
Kind regard
Jean-Marc
To cleaning my app i need to know if word 2 of a message which begin by "on" is s reserved word.
I tried
put ("mouseup" is reserved)
but i'm surprised that it return "false"
Thanks for your lights
Kind regard
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9752
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: reserved word or not ?
Jean-marc.
I think the problem is that "reserved' is not reserved.
When you asked LC to evaluate "mouseup is reserved", it returned "false", just as if you asked "4 = 5".
Craig
I think the problem is that "reserved' is not reserved.
When you asked LC to evaluate "mouseup is reserved", it returned "false", just as if you asked "4 = 5".
Craig
Last edited by dunbarx on Fri Dec 16, 2022 7:15 pm, edited 2 times in total.
-
- VIP Livecode Opensource Backer
- Posts: 9752
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: reserved word or not ?
Jean-Marc.
What is an example of a line of code that you are concerned about?
Craig
What is an example of a line of code that you are concerned about?
Craig
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: reserved word or not ?
I want change all of my commands and functions to private handlers.
Something like that
"private command MyHandler" instead "on MyHandler"
The reason is that I am looking for a successor to maintain my app and I think it would be clearer if he can know right away if a handler comes from livecode or if it is a personal handler.
Klaus having introduced me to laziness , I wonder if one script using reserved word could do the job in the whole application.
Jean-Marc
Something like that
"private command MyHandler" instead "on MyHandler"
The reason is that I am looking for a successor to maintain my app and I think it would be clearer if he can know right away if a handler comes from livecode or if it is a personal handler.
Klaus having introduced me to laziness , I wonder if one script using reserved word could do the job in the whole application.
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9752
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: reserved word or not ?
Hmm.
Can you (untested):
??
Craig
Can you (untested):
Code: Select all
put the script of yourScript into temp
repeat for each line tLine in temp
if word 1 of tLine = "on" then replace "on" with "command" in tLine
put tLine & return after newSCript
set the script of yourScript to newScript
Craig
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: reserved word or not ?
Hi Craig,
Yes, but with one more condition:
Jean-Marc
Yes, but with one more condition:
Code: Select all
if word 1 of tLine = "on" and word 2 of tLine is not a reserved word then replace "on" with "command" in tLine
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9857
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: reserved word or not ?
What will you do for functions?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: reserved word or not ?
I don't think functions are going to be a problem.
You can get a list of the built-in functions by requesting "the functionnames", but if it's possible to override one of them (if for instance one is in a backscript or other library script) then it's something you've explicitly done.
The reserved words in question here fall more under the category of "messages", and there's no way I know of to get a list of the messages that are handled by the system. I'd love to have an easy way to get that list the way we can get the commandnames or functionnames. But there isn't one that I'm aware of.
You can get a list of the built-in functions by requesting "the functionnames", but if it's possible to override one of them (if for instance one is in a backscript or other library script) then it's something you've explicitly done.
The reserved words in question here fall more under the category of "messages", and there's no way I know of to get a list of the messages that are handled by the system. I'd love to have an easy way to get that list the way we can get the commandnames or functionnames. But there isn't one that I'm aware of.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: reserved word or not ?
The only thing I can think of is to somehow extract the content from the dictionary list and filter by type "message". Extracting from the dictionary would be the challenging part.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9857
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: reserved word or not ?
I put in a request for the messageNames a while back, but not many need it so I don't expect it soon.mwieder wrote: ↑Sun Dec 18, 2022 1:06 amI don't think functions are going to be a problem.
You can get a list of the built-in functions by requesting "the functionnames", but if it's possible to override one of them (if for instance one is in a backscript or other library script) then it's something you've explicitly done.
The reserved words in question here fall more under the category of "messages", and there's no way I know of to get a list of the messages that are handled by the system. I'd love to have an easy way to get that list the way we can get the commandnames or functionnames. But there isn't one that I'm aware of.
But being able to identify function names wasn't the root of my question here. I was asking about what to do with them once identified.
In this thread, identification is just a means to an end, the end being to alter them to use the more distinctive "command" rather than "on" to provide an even more explicit identification for a future maintainer.
Personally, I wouldn't pursue that route. It's more work than needed, and we have no equivalent of "command" for functions anyway.
Far simpler would be to distinguish with capitalization: TitleCaps for custom names (big things attract the eye), and lowerCase for generic engine stuff (the stuff we see all the time will usually be less noteworthy over a maintenance lifecycle).
If a clear, concise, and simple method for distinguishing between engine stuff and custom stuff doesn't go far enough, you haven't found the right person for maintaining your legacy app.
PS: Be careful with "private". It's not just for distinguishing custom stuff. It limits scope so it can't be called by anything outside the script it's in. If that's what you need, then use it. But adding it wholesale in an automated way as described in the OP would likely yield many "handler not found" errors.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: reserved word or not ?
Yes, and what I was trying to get at is... why do anything with them? There are two possible cases:But being able to identify function names wasn't the root of my question here. I was asking about what to do with them once identified.
1. If they're functions you created then they're yours, not the system's.
2. If you're overriding a system function in a frontscript then again they're yours, which resolves to case 1.
And point taken about private handlers. I use them a lot, and would use more if callback messages didn't have to be public. But it does take care to avoid getting into trouble.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9857
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: reserved word or not ?
Seems we're on the same page. If custom naming conventions to distinguish custom things are good enough for Charles Simonyi they're good enough for me.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 474
- Joined: Thu Sep 04, 2008 6:23 am
- Location: Melbourne Australia
Re: reserved word or not ?
The web API lists messages. According to the Dash docset there are 429 messages. If I remember correctly these should be in an sqlite db in the docset package. Or you can dive into the docset creator stack and just add a script snippet to write then out to a text file when you run it.
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: reserved word or not ?
The issue wasn't how to represent the two, but rather how to identify them. The docset idea might work.Far simpler would be to distinguish with capitalization: TitleCaps for custom names (big things attract the eye), and lowerCase for generic engine stuff
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9857
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: reserved word or not ?
Note why he wants to identify them:
I want change all of my commands and functions to private handlers.
Something like that
"private command MyHandler" instead "on MyHandler"
The reason is that I am looking for a successor to maintain my app and I think it would be clearer if he can know right away if a handler comes from livecode or if it is a personal handler.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn