I learn scripting

The forum for designers and developers.
User avatar
djjb
Posts: 128
Joined: 15. Nov 05, 13:41
Location: Geldrop / Holland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby djjb » 17. Nov 08, 08:07


SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby SilverEagle » 17. Nov 08, 08:37

Hi John,

You did not setup the array once, but every time verzoekCallback was called. And the message was stored in msglist[i] (after the loop when i is -1), not in msglist[0]. The rest is OK. I ran the example for you and it worked, see the attached 'skin'.

(The white area is a poor mans button - I got fed up with entering the menu while testing ;-)).

Cheers,
SilverEagle
Attachments
DjjbChatTest.sjs
(2.26 KiB) Downloaded 402 times
Last edited by SilverEagle on 18. Nov 08, 09:28, edited 1 time in total.

User avatar
djjb
Posts: 128
Joined: 15. Nov 05, 13:41
Location: Geldrop / Holland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby djjb » 18. Nov 08, 07:16

Attachments
thank_you_flowers.gif
Many many many thanks

Best regards,
John
thank_you_flowers.gif (30.67 KiB) Viewed 8014 times

User avatar
djjb
Posts: 128
Joined: 15. Nov 05, 13:41
Location: Geldrop / Holland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby djjb » 18. Nov 08, 09:18

Attachments
12.jpg
Here is my chatbox..
12.jpg (65.36 KiB) Viewed 8000 times

SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby SilverEagle » 18. Nov 08, 14:52

Last edited by SilverEagle on 18. Nov 08, 21:47, edited 1 time in total.

User avatar
djjb
Posts: 128
Joined: 15. Nov 05, 13:41
Location: Geldrop / Holland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby djjb » 18. Nov 08, 19:49


User avatar
djjb
Posts: 128
Joined: 15. Nov 05, 13:41
Location: Geldrop / Holland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby djjb » 19. Nov 08, 08:09

Hi again,
It seems like I'm not trying enough, but I realy don't know a thing about this hahahaha.
You told me what to do, but I don't know how to do...lol.

>SilverEagle wrote:

> Now when adding a msg, check for all elements in
> the array if that name equals the element. If
> none matched, add the new name to the array.

How do I check?
I tried the string.match(regexp); and also downloaded the regexp.test(input); script and see how it works, But I got lost..

This is what I have now. And I think it's just a 'if' thing that must be set intro the script, or am I wrong?

<script>
// this is just run once on startup
var msglist = new Array("", "", "", "")
var personlist = new Array("", "", "", "")
program.addMenuEntry('Bericht', verzoekCallback);
// end startup code

function verzoekCallback()
{
var d = new Dialog;
var i;
var p;

d.addStaticText('Text','Type hieronder een kort bericht van ongeveer 30 karakters. Je kunt je bericht lezen als het scherm wisselt (F1-toets)');
d.addTextCtrl('Naam',' naam:');
d.addStaticText(' Druk de Tab-toets om van naam naar bericht te gaan')
d.addTextCtrl('Bericht',' bericht:');
d.addButton('ok');
d.addButton('cancel');

if(d.showModal()=='ok')
{
// disbled just just for testing, i'm too lazy to click OK
// alert('Bedankt!\nDruk op de F1-toets om je bericht te bekijken.\nOok bij het wisselen van nummers kan iedereen jouw bericht lezen.')

for (i=3; i > 0; --i)
{
msglist[i] = msglist[i - 1];
}
msglist[0] = d.getValue('Naam') + ": " + d.getValue('Bericht');
for (i=3; i >= 0; --i)
{
program.setSkinText("msg" + i, msglist[i]);
}
{
for (p=3; p > 0; --p)
{
personlist[p] = personlist[p - 1];
}
personlist[0] = d.getValue('Naam');
for (p=3; p >= 0; --p)
{
program.setSkinText("person" + p, personlist[p]);
}
}
}
}


</script>

Sorry I'm a dummie.
I think I have to paste your logo in my skin...

Best regards,
John

SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby SilverEagle » 19. Nov 08, 10:32

Hi John,

(By the way: normally I'd take this to email, but as there are not that much scripting examples on the forum I thought maybe someone else would find this informative as well.)

Attached a working example. It now shows a list of people participating in the chat with the most recent one on top (or was it bottom?).

Not as simple as it might be, seems you cannot remove an item from the middle of an array, so I made a temporay copy.

> I think I have to paste your logo in my skin...

No, you certainly don't need to do that. Just add my copyright to the source and we'll have my people send your people the invoice ;-)

Regards,
SilverEagle
PS: Yes, I _was_ kidding about the copyright...
Attachments
DjjbChatTest2.sjs
(1.53 KiB) Downloaded 406 times

User avatar
djjb
Posts: 128
Joined: 15. Nov 05, 13:41
Location: Geldrop / Holland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby djjb » 19. Nov 08, 10:51

Hi again..
Well ..that's more coplicated as I tought.
I tried your Test and it's great. I did make a litle change in it because the 4th box wasn't used. When I changed the 3 in 4 it whas ok..(me cool! :o()

for (i = 0; (i < 4) && (i < personlist.length); ++i)
for (i=0; i < 4; ++i)

Again thanks a lot for your help, Ow and sorry I couldn't wait for 1 day. I was drowning in the ()[]{}/\,:;"'<>...



Best regards,
John

User avatar
djjb
Posts: 128
Joined: 15. Nov 05, 13:41
Location: Geldrop / Holland
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: I learn scripting

Postby djjb » 27. Nov 08, 07:52



[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Return to “Developer Network”