Autocompletion

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Autocompletion

Post by gilgml » Tue Aug 24, 2021 10:58 pm

Hey there, vibrant and helpful community :D

I am thinking about buying community +

I have a question about Autocompletion :
Does it show you the identifiers you declared/used above or before in the stack ?

If i remember well, visual studio code did it.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Autocompletion

Post by dunbarx » Wed Aug 25, 2021 2:15 pm

Hi.

Do you mean the "Options" submenu in the "Edit" menu, while the SE is in front?

And by "identifiers", do you mean variables?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: Autocompletion

Post by richmond62 » Wed Aug 25, 2021 2:55 pm

I suppose Autocompletion may be a good thing.

Personally I have turned it off in all the Apps on both my Android phone and my Android tablet,
and anywhere else: it is almost as bad as spelling correxion that forces me to use either American
spelling or "British" English spelling.

Also those double speech marks that keep doubling all over the place just stick in my
craw.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Autocompletion

Post by dunbarx » Wed Aug 25, 2021 5:07 pm

Is "autoCompletion" really the right word? LC has automatic SE aids, like "bracket completion", and "control structure completion", all in that "Options" subMenu, but gilgmi, is that what you meant?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Autocompletion

Post by dunbarx » Wed Aug 25, 2021 5:09 pm

And I am much with Richmond here. I only use "Live Errors", "Control structure completion" and "autoFormat".

NEVER the others.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: Autocompletion

Post by richmond62 » Wed Aug 25, 2021 8:42 pm

I am much with Richmond here
Be careful, you may get blacklisted. :D

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Re: Autocompletion

Post by gilgml » Fri Aug 27, 2021 2:26 pm

Hello !

Sorry for keeping you waiting because i thought i was Email notified, and was not.

If it is a source of trouble, i will double check, but about identifiers i meant variable names yes, and command and function names.
IMHO, this is were it becomes really handy.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Autocompletion

Post by dunbarx » Sat Aug 28, 2021 5:29 am

Hi.

So if you check "variable checking"in the Option menu wihile the SE is in front, or select "strict compilation mode" in the SE preferences, then if you do NOT declare your variables, the SE will not let you proceed.

But that is still different from autoCompletion, or at least what I think that word actually means.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Autocompletion

Post by jacque » Sat Aug 28, 2021 5:01 pm

I don't use autocomplete either, but if I remember right it did complete variable names if they were used in the same handler. I'm not sure if it also completes variables anywhere in the same script.

Command and function handler declarations are automatically completed with the "end" statement, also control structures and paired characters like parentheses, quotation marks, brackets, etc. You can disable any of these features if you don't want them.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Re: Autocompletion

Post by gilgml » Sat Aug 28, 2021 8:07 pm

Thank you.

I was wondering for variable autocompletion, if possible across handlers, and anywhere in the same script.
And also command and function names.

Thank you jacque, i noticed the very handy 'pairing' of brackets and etc and control structures.

Not worth the price, so.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Autocompletion

Post by jacque » Sat Aug 28, 2021 11:40 pm

I just tried it. Auto-completion depends on the scope of the variable. That means that global variables and script-local variables complete anywhere if they are declared in the script. Variables that occur only within a handler will auto-complete within that handler, but are removed from memory when the handler completes.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

golife
Posts: 115
Joined: Fri Apr 02, 2010 12:10 pm

Re: Autocompletion

Post by golife » Sun Aug 29, 2021 4:58 pm

Besides, that is it good practice, even "best practice", to declare all variables, the autocompletion so much goes in the way for a fast typist (such as me) so that I turn it off my default. I can write faster than I can think... :o

But I have another question regarding autocomplete: I want to autocomplete tags (labels) that users enter for a given subject. Once completed, they form a group that contains this one phrase or word and receive colors and are in a box. They appear usually in one row horizontally, eventually create new rows. Each of them can be clicked away and the list can be reordered through drag and drop by the user. Maybe someone has already done something like this? (So far, I am using a type-forward list field, but it is not such a good solution in this specific case).

Roland

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Autocompletion

Post by dunbarx » Mon Aug 30, 2021 4:27 am

Hi.

It sounds like what you want is far outside the capabilities of any type of built-in autoComplete.

But it can be scripted easily. Please give an example of some initial text, and the resultant text your want after the user has gotten hold of it.

The drag and drop gadget you describe has been done in several ways by several people here. I can give you an example of the way I have done it, but let us do the tag/label thing first.

Craig

golife
Posts: 115
Joined: Fri Apr 02, 2010 12:10 pm

Re: Autocompletion

Post by golife » Mon Aug 30, 2021 5:02 pm

@: dunbarx on 29 Aug 2021, 23:27

Thank you dubarx

Well, the list is for example "LiveCode Builder, LIveCode Script, Private, Business school".

These are items, and the items will be tags. If the tag exists, it is autocompleted, otherwise it is added to the tag list.

So, users would enter words and phrases. It is easy to separate the items as long as there is a comma delimiter. But I currently do not have the handler to autocomplete when the user start typing.

Items that have been identified (new or existing) will be a group with a checkbox that allows the user to click them away. Deletion is just another variant, desired, or not. Items appear one after the other. Also not a problem. This is clear.

But how to make autocomplete work nicely without obstructing the work flow of the user while typing... ? So, let the user start when more than 3 characters were typed... rawkeydown, closefield, backspace, ... find one or more phrases that would autocomplete the word/phrase and let the user select without obstructing...

I can work on it, but if there is a slick solution already, why do the work twice?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Autocompletion

Post by dunbarx » Mon Aug 30, 2021 8:36 pm

Fun, fun fun.

Here are two experiments I made that autoComplete text. Both work. A textChanged handler in the yellow fields does the work. Click on one of the buttons, and start typing in the yellow field that gains focus. Any word in the "source" field above that field will autoComplete at three chars.

The problem is when a compound word lives within an item. To be able to discriminate between, say, "LiveCode builder" and "LiveCode Script", using only a few characters as a seed is the issue. You can always change the "3' in the "compound" "textChanged" handler to "10". But that makes general usage far less valuable.

I can think of several kludges that will solve this, perhaps by temporarily combining all compound words within each item into a single word and then restoring the space(s). Want to tackle that?

Craig
autoComplete.livecode.zip
(1.37 KiB) Downloaded 195 times

Post Reply