Isn’t “external screen example()” possible or is it wrong syntax? I got “Syntax error near unexpected token ‘)’”

Submitted by Terje Pedersen on 18 March 2011 at 12:06

On 18 March 2011 at 12:09 Zef Hemel commented:

Gosh, clearly nobody used this before. For some reason the syntax was:

external screen example : void ()

I’ll fix this in 0.4.2.


On 18 March 2011 at 12:09 Zef Hemel tagged 0.4.2

On 18 March 2011 at 14:29 Terje Pedersen commented:

When using external screen example : void () instead I got “Uncaught TypeError: Cannot call method ‘get’ of undefined” from mobl.js:676 most likely the fix for 0.4.2 will fix it aswell.


On 18 March 2011 at 14:30 Zef Hemel commented:

Yes, you really cannot use it right now. Internally it was also broken.


On 18 March 2011 at 15:54 Zef Hemel closed this issue.

On 23 March 2011 at 12:53 Terje Pedersen commented:

external screen example()

I now get “Syntax error, not expected here: ‘screen’” and “Syntax error, expected: ‘middleware’”

Trying to add return type “: void” get rid of the errors but calling example() nothing happens.


On 23 March 2011 at 13:04 Zef Hemel commented:

You should indeed add : void there. When you call it, well, it calls the Javascript function your.module.example(.., ...) (which should mimic the behavior of a generated screen).

What are you trying to do exactly?


On 23 March 2011 at 13:46 Terje Pedersen commented:

I have two modules one of them loaded. I’ve got external control working but external screen gives me currently “Cannot call method ‘get’ of undefined”


On 23 March 2011 at 13:57 Zef Hemel commented:

Can you show (or send me) some code that reproduces this? You can use < verbatim> (no space after <) for code in this bug tracker.


On 23 March 2011 at 14:07 Terje Pedersen commented:

uni.mobl

module uni

dynamic import uni1
dynamic import uni2

external control hello()
external screen example() : void

some logic for switching between them but using only this below gives the same error



mobl.load(‘uni1.js’);
uni.impl = uni1;
mobl.implementInterface(uni.impl, uni, [‘hello’,‘example’]);

uni1.mobl

module uni1
import mobl::ui::generic

control hello() {
label(“hello from 1”)
}

screen example() {
header(“1111”)
}

uni2.mobl

module uni2
import mobl::ui::generic

control hello() {
label(“hello from 2”)
}

screen example() {
header(“2222”)
}

In my main module

screen root() {
hello()
button(“call example()”, onclick={example();})
}


On 23 March 2011 at 21:09 Zef Hemel reopened this issue.

On 23 March 2011 at 21:45 Zef Hemel tagged 0.4.3

On 23 March 2011 at 21:45 Zef Hemel removed tag 0.4.2

On 23 March 2011 at 21:49 Zef Hemel commented:

Alright, there was still a bug there. I forgot that in a recent update every screen got two optional arguments, implicitly added (replace and animate) and that is not handled well in this case. I’ll fix this in 0.4.3. Here’s how you can get it to work now:


application uni

import mobl::ui::generic

dynamic import uni1
dynamic import uni2

external control hello()
external screen example(replace : Bool = false, animate : String = “slide”) : void

// in 0.4.3 you’ll be able to write:
// external screen example() : void


mobl.load(‘uni1.js’);
mobl.implementInterface(uni1, __ns, [‘hello’,‘example’]);

screen root() {
hello()
button(“call example()”, onclick={example();})
}

What I changed in addition is the the mobl.implementInterface line, this basically hooks the definitions uni1.hello and uni1.example into __ns.hello and __ns.example respectively.

Again, it’s a bit of a hack now (with the replace and animate arguments), but you can get rid of those in the next release.


On 23 March 2011 at 22:16 Terje Pedersen commented:

Worked :) Good to know its going to be improved in 0.4.3


On 25 March 2011 at 14:29 Zef Hemel closed this issue.

Log in to post comments