# An othe idea for Global Agent Method

**URL:** <https://forum.servoy.com/t/an-othe-idea-for-global-agent-method/3552>\
**Category:** Classic Servoy\
**Created:** [January 27, 2005, 11:18am UTC](https://forum.servoy.com/t/an-othe-idea-for-global-agent-method/3552 "2005-01-27T11:18:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elmono\_acosta](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@elmono\_acosta](https://forum.servoy.com/u/elmono_acosta)\
**Post date:** [January 27, 2005, 11:18am UTC](https://forum.servoy.com/t/an-othe-idea-for-global-agent-method/3552/1 "2005-01-27T11:18:36Z")

</div>

Call this method form anywhere, and forget about the size of the ballon…

globals.callAgent(‘This is a test for the agent…bla…bla…’);

The method is

```auto
plugins.agent.show();

//Determines correct size of the baloon, depending on the amount of text.

var number_of_letters= arguments[0].length;

var c = 0;
var i = 0;
while ((i=arguments[0].indexOf("\n",i))!=-1) {
	i++;
	c++;
}

var hight = (((number_of_letters / 28)+c) * 16) + 21;

plugins.agent.setBalloonSize(200,hight);
plugins.agent.speak(arguments[0]);

//Servoy will automatically hide the baloon (time not adjustable, servoy handles it automatically. Not very good...)
//But the image of the agent will still be displayed, after the baloon hides.
//To hide the image, do this:
//The number is in seconds * 1000

var startDate = new Date();
startDate.setTime(startDate.getTime()+5000);
plugins.scheduler.addJob('HideAgent'+ startDate.getTime(),startDate,globals.hideAgent);

```

The method globals.hideAgent is:

```auto
plugins.agent.hide();

```

What this is missing is been able to hide BOTH the baloon an Agent at the same time. (of course an adjustable time. !!!)  
Any ideas ???  
Maybe this should all be a funtion of servoy ???

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [January 28, 2005, 1:46am UTC](https://forum.servoy.com/t/an-othe-idea-for-global-agent-method/3552/2 "2005-01-28T01:46:30Z")

</div>

The plug-ins we provide for free are meant as examples. They are FUNCTIONAL examples, but examples nonetheless.

The source of this bean is open. You can change it however you want via Java.
