Jump to content




A question to shell.setCompletionFunction


  • You cannot reply to this topic
9 replies to this topic

#1 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 07 April 2016 - 07:20 PM

I programmed a new edit and set the alias.
I tried to set the completion function:
shell.setCompletionFunction(customEditPath, shell.getCompletionInfo()['rom/programs/edit'])
What did I wrong?

And by the way, how works the set completion function?

#2 EveryOS

  • Members
  • 570 posts
  • LocationOver there ->

Posted 07 April 2016 - 07:33 PM

function shell.setCompletionFunction( sProgram, fnComplete )
  tCompletionInfo[ sProgram ] = {
	 fnComplete = fnComplete
   }
end

Edited by everyOS, 07 April 2016 - 09:44 PM.


#3 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 07 April 2016 - 10:44 PM

View PosteveryOS, on 07 April 2016 - 07:33 PM, said:

function shell.setCompletionFunction( sProgram, fnComplete )
  tCompletionInfo[ sProgram ] = {
	 fnComplete = fnComplete
   }
end

Why my completion doesn't work?

shell.setCompletionFunction(customEditPath, shell.getCompletionInfo()['rom/programs/edit'])

Edited by Sewbacca, 07 April 2016 - 10:45 PM.


#4 EveryOS

  • Members
  • 570 posts
  • LocationOver there ->

Posted 07 April 2016 - 11:33 PM

sewbacca said:

and how works the set completion function?


#5 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 08 April 2016 - 01:28 AM

When a variable is prefixed by fn, that means it's supposed to be a function. Furthermore, if a function name includes function in it, there's a pretty good chance that it wants a function.

TL;DR: Give it a function, not the completion info for 'rom/programs/edit'

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 08 April 2016 - 02:53 AM

View PostKingofGamesYami, on 08 April 2016 - 01:28 AM, said:

TL;DR: Give it a function, not the completion info for 'rom/programs/edit'

The completion info for 'rom/programs/edit' is, in fact, a function.

Relevant code:

shell.setCompletionFunction( sProgram, fnComplete )

shell.getCompletionInfo()

"rom/programs/edit" key in tCompletionInfo table gets set

So I guess the question is, "what's the value of customEditPath"? Is a path set to it?

#7 CoderPuppy

  • Members
  • 121 posts

Posted 08 April 2016 - 04:02 AM

View PostBomb Bloke, on 08 April 2016 - 02:53 AM, said:

The completion info for 'rom/programs/edit' is, in fact, a function.

No, the completion info is a table with an "fnComplete" key.

This should work (untested):
shell.setCompletionFunction(customEditPath, shell.getCompletionInfo()['rom/programs/edit'].fnComplete)


#8 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 08 April 2016 - 04:06 AM

*headdesk*

Yes, I'd say you've got it. :)

#9 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 08 April 2016 - 08:26 PM

View PostCoderPuppy, on 08 April 2016 - 04:02 AM, said:

View PostBomb Bloke, on 08 April 2016 - 02:53 AM, said:

The completion info for 'rom/programs/edit' is, in fact, a function.

No, the completion info is a table with an "fnComplete" key.

This should work (untested):
shell.setCompletionFunction(customEditPath, shell.getCompletionInfo()['rom/programs/edit'].fnComplete)

Doesn't work: table expected got function

#10 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 08 April 2016 - 08:55 PM

That code should work, can you show us what your code looks like?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users