DroidScript unexpected end of token - droidscript

It says exactly this. I don't think I made a mistake. Here is my code:
function OnStart()
{
list=app.LoadText("List");
lvw= app.CreateListView(list,"Lego");
lvw.SetOnTouch( lvw_OnTouch );
lvw.Show();
}
app.EnableBackKey( "false" );
function lvw_OnTouch( item )
{
if(item=="Add Item"){
to=app.LoadText( "List" );
//Create dialog window.
dlgTxt = app.CreateDialog( "Add Item" );
//Create a layout for dialog.
layDlg = app.CreateLayout( "linear", "vertical,fillxy,left" );
layDlg.SetPadding( 0.02, 0, 0.02,
0.02 );
dlgTxt.AddLayout( layDlg );
lstDlg = app.CreateTextEdit("");
lstDlg.SetHint( "*******Item ID here*******" );
lstDlg.SetPadding( 0.0, 0, 0.02,
0.02);
lstDlg.SetTextColor( "#dddddd" );
layDlg.AddChild( lstDlg );
lstDlg.SetOnEnter( enter );
amount= app.CreateTextEdit("");
amount.SetHint( "*******Item Amount*******" );
amount.SetPadding( 0.0, 0, 0.02,
0.02);
amount.SetTextColor( "#dddddd" );
layDlg.AddChild( amount);
amount.SetOnEnter( enter );
//Show dialog.
dlgTxt.Show();
}else if(item=="Reset"){
var yesno=app.CreateYesNoDialog("Do you really want to reset?");
yesno.SetOnTouch(yesnores);
yesno.Show();
}else if(item=="Exit App"){
app.Exit( );
}else{
lvw.Show();
}
function enter()
{
dlgTxt.Hide();
lvw.Show();
app.SaveText("List",to+","+lstDlg.GetText()+" "+amount.GetText());
}
function OnBack()
{
app.Exit( );
}
function yesnores(result)
{
if(result=="Yes")
{app.SaveText("List","Add
Item,Reset,Exit App");
}else lvw.Show();
}
}
I checked the code again and again but no result, I can't find what causes the error. Don't forget that is not javascript, that is DroidScript, that is different from javascript. The app needs to hold values they are coming from user when user hits Add Item, the list should be resetten when user presses Reset and the user should exit from the app with just one click to Exit App.

You have a line break in the middle of a string
This should be all one line
app.SaveText("List","Add Item,Reset,Exit App");

click on debug check what is happening
it shows her the problem that is occurring

Related

[mxGraph]Changing the preview style of the cell dragged from the toolbar as to center my cursor on the preview, but the guild line doesn't fit along

By default, the cursor is at the left-top of the preview cell .
I've changed the relative position of the preview using transform: translate(-50%, -50%),so the cursor can be at the center on the preview while dragging.
But then I find the guide line doesn't fit along with the changed preview, it's still works according to the original position of the preview.
I've tried some 'offset' API on the docs but still can't work it out.
In this pic, I draw the red box, which is the original position of the preview, and the guide line works wrong
functions concerning the question are on below
const draggingPreview = () => {
const elt = document.createElement("div");
elt.style.width = '60px';
elt.style.height = '60px';
elt.style.transform = "translate(-50%,-50%)";
return elt;
};
const dropHandler = (graph, evt, dropCell, x, y) => {
const parent = graph.getDefaultParent();
this.graph.getModel().beginUpdate();
try {
let vertex = this.graph.insertVertex(
parent,
null,
null,
x - 30,
y - 30,
width,
height,
style
);
vertex.value = "xxxx";
} finally {
this.graph.getModel().endUpdate();
}
};
const ds = mxUtils.makeDraggable(
dom,
graph,
dropHandler,
draggingPreview(),
0,
0,
true,
true
);
ds.setGuidesEnabled(true);

Any function in DMS3.0 or later that runs in the background and allow user interaction (like FloatingModelessDialog)

In DMS3.42 or later, I am wondering if we have a function that the user is allowed to select an image to operate. Basically, the function needs to run in the background and allows user interaction, something like "FloatingModelessDialog" in the previous version (it seems "FloatingModelessDialog" is not supported in DMS3.0).
Thank you!
FloatingModelessDialog is still supported in GMS 3:
// $BACKGROUND$
number sem = NewSemaphore()
FloatingModelessDialog("Message", "YES", sem )
Result("\n Do continue stuff...")
// hold and wait for the dialog
number OK
Try { GrabSemaphore(sem); OK = 1; }
catch { OK = 0; break; }
Result("\n Button pressed:" + OK )
However, this is only a workaround solution and requires the script to be executed on a background thread (or GMS appears to be frozen.)
A more complete approach would be to create a dialog and have its buttons drive the actions, like in the example below:
class MyActionDialog : UIFrame{
void Launch( object self ){
// Build dialog
TagGroup DLGtgs, DLGItems
DLGtgs = DLGCreateDialog( "My Dialog", DLGItems )
TagGroup Button1 = DLGCreatePushButton( "Act on front image", "OnButtonAct" )
TagGroup Button2 = DLGCreatePushButton( "Close", "OnButtonClose" )
DLGItems.DLGAddElement( Button1 )
DLGItems.DLGAddElement( Button2 )
DLGtgs.DLGTableLayout( 2, 1, 0 )
// Create and display the modeless Dialog
self.init( DLGtgs )
self.Display( "My Dialog" )
}
void OnButtonAct( object self ){
image front
if ( !GetFrontImage(front) )
Result( "\n Please select an image first." )
else
Result("\n Acting on image [" + front.ImageGetLabel() + "]....")
}
void OnButtonClose( object self ){
Result( "\n Closing dialog actions." )
self.close()
}
}
Alloc(MyActionDialog).Launch()

How can I wait for an animation to be finished without using a sleep in selenium using perl?

I have observed that when I fill a form with selectboxes it does not fill up correclty (it seems like sometimes the option is not selected) if I fill all parameters without a sleep between the click to open the select box and the click to select an option.
If I have a sleep between the first click and the second it seems to work properly, but if I have a big set of select boxes filling the forms slows down a lot.
Is there a way to do this in some kind of "wait for an animation to be finished"? This is the code I'm using simplified:
use strict;
use warnings;
use Selenium::Chrome;
use Selenium::Waiter qw/wait_until/;
my $chrome_driver_path = "chromedriver.exe";
my $driver;
my %settings = (
'binary' => $chrome_driver_path,
);
$driver = Selenium::Chrome->new(%settings);
$driver->get("http://mywebiste.com/myform_with_selectbox");
_set_select_box($driver, "myoption");
sub _set_select_box{
my ($driver, $input) = #_;
# Open selectbox
my $element_id = 'some_label';
my $element;
wait_until{ $element = ($driver->find_elements("//label[\#id='$element_id']"))[0] };
if (defined($element)){
$log->debug("element_id: '$element_id' found");
}else{
$log->error("element_id: '$element_id' could not be found");
return -1;
}
wait_until{$element->click()};
$log->debug("element_id '$element_id' clicked");
# sleep(1); here I put a sleep and it seems to work always
# Click item in selectbox
my $element_2_id = 'some_items';
my #elements;
wait_until{ #elements = ($driver->find_elements("//ul[\#id='$element_2_id']//li")) };
if (defined($elements[0])){
$log->debug("element_2_id: '$element_2_id' found");
}else{
$log->error("element_2_id: '$element_2_id' could not be found");
return -1;
}
my $selectbox_text = $config->val( 'MyOptions', $input);
return -1 if (!defined($selectbox_text));
foreach my $element_2 (#elements){
my $option_text = $element_2->get_text();
$option_text = encode('UTF-8', $option_text, Encode::FB_CROAK) if (defined($option_text)); # otherwise selenium does not return utf8
if ($option_text eq $selectbox_text){
$log->debug("selectbox_text '$selectbox_text' found");
wait_until{$element_2->click()};
$log->debug("selectbox_text '$selectbox_text' clicked");
return 1;
}else{
$log->debug("Selectbox text does not match Found: '$option_text' Expected '$selectbox_text'");
}
}
return 0;
}

Collision Physics P2 and Arcade not working as desired

Hi all so I have a small problem, basically I'm trying to kill a moving sprite, it does not matters if it comes from left to right or right to left, but all I want to kill is the one colliding and not the whole group, so to test go to the far right and shoot the block, you will see the new block disappear but not the one that collided is this possible I'm providing my game.js below but I created a demo that you can download and test to get a better feel of my problem please help, thanks.
Link to Demo
BasicGame.Game = function (game) {
// When a State is added to Phaser it automatically has the following properties set on it, even if they already exist:
this.game; // a reference to the currently running game (Phaser.Game)
this.add; // used to add sprites, text, groups, etc (Phaser.GameObjectFactory)
this.camera; // a reference to the game camera (Phaser.Camera)
this.cache; // the game cache (Phaser.Cache)
this.input; // the global input manager. You can access this.input.keyboard, this.input.mouse, as well from it. (Phaser.Input)
this.load; // for preloading assets (Phaser.Loader)
this.math; // lots of useful common math operations (Phaser.Math)
this.sound; // the sound manager - add a sound, play one, set-up markers, etc (Phaser.SoundManager)
this.stage; // the game stage (Phaser.Stage)
this.time; // the clock (Phaser.Time)
this.tweens; // the tween manager (Phaser.TweenManager)
this.state; // the state manager (Phaser.StateManager)
this.world; // the game world (Phaser.World)
this.particles; // the particle manager (Phaser.Particles)
this.physics; // the physics manager (Phaser.Physics)
this.rnd; // the repeatable random number generator (Phaser.RandomDataGenerator)
// You can use any of these from any function within this State.
// But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference.
this.bulletTimer = 0;
};
BasicGame.Game.prototype = {
create: function () {
//Enable physics
// Set the physics system
this.game.physics.startSystem(Phaser.Physics.ARCADE);
//End of physics
// Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out!
this.createBullets();
this.createTanque();
this.makeOneBloque();
this.timerBloques = this.time.events.loop(1500, this.makeBloques, this);
},
update: function () {
if(this.game.input.activePointer.isDown){
this.fireBullet();
}
this.game.physics.arcade.overlap(this.bullets, this.bloque, this.collisionBulletBloque, null, this);
},
createBullets: function() {
this.bullets = this.game.add.group();
this.bullets.enableBody = true;
this.bullets.physicsBodyType = Phaser.Physics.ARCADE;
this.bullets.createMultiple(100, 'bulletSprite');
this.bullets.setAll('anchor.x', 0.5);
this.bullets.setAll('anchor.y', 1);
this.bullets.setAll('outOfBoundsKill', true);
this.bullets.setAll('checkWorldBounds', true);
},
fireBullet: function(){
if (this.bulletTimer < this.game.time.time) {
this.bulletTimer = this.game.time.time + 1400;
this.bullet = this.bullets.getFirstExists(false);
if (this.bullet) {
this.bullet.reset(this.tanque.x, this.tanque.y - 20);
this.bullet.body.velocity.y = -800;
}
}
},
makeOneBloque: function(){
this.bloquecs = ["bloqueSprite","bloquelSprite"];
this.bloque = this.game.add.group();
for (var i = 0; i < 4; i++){
this.bloque.createMultiple(5, this.bloquecs[Math.floor(Math.random()*this.bloquecs.length)], 0, false);
}
this.bloque.enableBody = true;
this.game.physics.arcade.enable(this.bloque);
this.bloque.setAll('anchor.x', 0.5);
this.bloque.setAll('anchor.y', 0.5);
this.bloque.setAll('outOfBoundsKill', true);
this.bloque.setAll('checkWorldBounds', true);
},
makeBloques: function(){
this.bloques = this.bloque.getFirstExists(false);
if (this.bloques) {
this.bloques.reset(0, 300);
this.bloques.body.kinematic = true;
this.bloques.body.velocity.x = 500;
}
},
createTanque: function() {
this.tanqueBounds = new Phaser.Rectangle(0, 600, 1024, 150);
this.tanque = this.add.sprite(500, 700, 'tanqueSprite');
this.tanque.inputEnabled = true;
this.tanque.input.enableDrag(true);
this.tanque.anchor.setTo(0.5,0.5);
this.tanque.input.boundsRect = this.tanqueBounds;
},
collisionBulletBloque: function(bullet, bloques) {
this.bloques.kill();
this.bullet.kill();
},
quitGame: function (pointer) {
// Here you should destroy anything you no longer need.
// Stop music, delete sprites, purge caches, free resources, all that good stuff.
// Then let's go back to the main menu.
this.state.start('MainMenu');
}
};

Can't get selenium to wait - tests only working when stepping through manually

I have quite a fundamental problem that none of my selenium phpunit tests pass unless I step through them manually in debug view, which is obviously a bit of an inconvenience! I'm running a local selenium server from the following jar file and executing the phpunit test from within Zend Studio 8.
selenium-server-standalone-2.0b2.jar
I can't seem to find anything relevant on google or by searching here, so I assume I must be doing something wrong. Here is an example method I call from the start of most test methods in order to log in.
protected function login() {
$this->open ( "/login.php" );
try {
$this->waitForPageToLoad ( "30000" );
$this->type ( "username", self::MA_USERNAME );
$this->type ( "password", self::MA_PASSWORD );
$this->click ( "//input[#value=' Login ']" );
$this->waitForPageToLoad ( "60000" );
$this->assertFalse( $this->isTextPresent( "Login details supplied are invalid." ) );
} catch ( PHPUnit_Framework_AssertionFailedError $e ) {
array_push ( $this->verificationErrors, $e->toString () );
}
}
If I just press 'run' and let it go then it doesn't even fill in the fields or submit the form, so I'm assuming it hasn't waited for the page to load despite having the waitForPageToLoad() call. Stepping through manually works perfectly. Can anyone suggest how to fix this? Thanks.
Seems like Selenium is executing commands way to quick. I had the same problem.
The way I fixed my problem was to use the function setSpeed($timeInMilliSec)
In php:
$this->setSpeed('120');
So in your function, try this:
protected function login() {
$this->open ( "/login.php" );
$this->setSpeed('120');
try {
$this->waitForPageToLoad ( "30000" );
$this->type ( "username", self::MA_USERNAME );
$this->type ( "password", self::MA_PASSWORD );
$this->click ( "//input[#value=' Login ']" );
$this->waitForPageToLoad ( "60000" );
$this->assertFalse( $this->isTextPresent( "Login details supplied are invalid." ) );
} catch ( PHPUnit_Framework_AssertionFailedError $e ) {
array_push ( $this->verificationErrors, $e->toString () );
}
}
Hope this fixes your problem