Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-23-2007, 04:27 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Scripting: obj.getstringkeys(str)

PHP Code:
function onCreated()
{
  array = {
"item1""item2"};
  for(
item : array.getstringkeys("item"))
    echo(
item);

Could be nice to do something like this
__________________
Reply With Quote
  #2  
Old 05-23-2007, 05:10 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
if you need that functionality you can use my associative array: http://forums.graalonline.com/forums...ad.php?t=68643
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #3  
Old 05-23-2007, 05:15 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by JkWhoSaysNi View Post
if you need that functionality you can use my associative array: http://forums.graalonline.com/forums...ad.php?t=68643
huh?
Which function?
__________________
Reply With Quote
  #4  
Old 05-23-2007, 05:24 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
It's a class for an associative array data structure. All it does really is map two arrays to each other.

{key1, key2}
{value1, value2}

all array.item(key1) does is find the index of key1 (in this case zero) and return the value at the same index (value1).

I provided functionality for looping through which is in the example usage.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #5  
Old 05-23-2007, 05:34 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
I don't see how this helps me

I want to do something like:

PHP Code:
function onCreated()
{
  array = {
"foo1""foo2""bar1""foo3""baz1"};
  for(
item : array.getstringkeys("foo"))
    echo(
item);

which would produce
HTML Code:
1
2
3
Instead of making a public function for it

If your class can do that, please give me an example?
__________________
Reply With Quote
  #6  
Old 05-23-2007, 05:37 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
.pos()?
Reply With Quote
  #7  
Old 05-23-2007, 05:40 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by DustyPorViva View Post
.pos()?
obj.pos would only get the first string, but obj.pos and obj.positions is for strings :O
__________________
Reply With Quote
  #8  
Old 05-23-2007, 05:54 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Good point, though I guess you can do something like:
PHP Code:
function onCreated() {
  array = {
"foo1""foo2""bar1""foo3""baz1"};
  for(
item : array.size())
    if (array[
item].pos("foo")>-1) echo(item);

Hmm, as for the suggestion, I think it's good. Of course I think anything that benefits in someway and makes things easier is a good idea. Though many seem to think if it's possible to work around there's no need to make such an addition. Phooey.

Last edited by DustyPorViva; 05-23-2007 at 06:12 PM..
Reply With Quote
  #9  
Old 05-23-2007, 06:02 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
oh, i see. Nevermind, i thought you meant something else.

You could do something like:

PHP Code:
array = {"foo1""foo2""bar1""foo3""baz1"};

for (
0;i<=array.size()-1;i++) {
if (array[
i].starts("foo")) {
echo(
i);
}

__________________

Coming soon (Hopefully:P)
Reply With Quote
  #10  
Old 05-23-2007, 07:42 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Use Dustys version!

HTML Code:
for (temp.currentArray: array)
{
  if (temp.currentArray.pos("foo") >= 0)
  {
    soforth
  }
}
Although, I wouldn't mind it being added too.
__________________
Reply With Quote
  #11  
Old 05-23-2007, 07:44 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Yeah, but then to echo 1,2,3 you have to create a counter anyway or then do array.index(temp.currentarray);
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #12  
Old 05-23-2007, 07:53 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by JkWhoSaysNi View Post
Yeah, but then to echo 1,2,3 you have to create a counter anyway or then do array.index(temp.currentarray);
no.

HTML Code:
for (temp.currentArray: array)
{
  if (temp.currentArray.pos("foo") >= 0)
  {  
    echo(temp.currentArray.substring(3));
  }
}
__________________
Reply With Quote
  #13  
Old 05-23-2007, 07:58 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy

You edited your post

PHP Code:
for (temp.currentArray: array)
{
  if (
temp.currentArray.pos("foo") >= 0)
  {  
    echo(
temp.currentArray.substring("foo".length()));
  }

But I would like this to be added
__________________
Reply With Quote
  #14  
Old 05-23-2007, 08:01 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Yeah
I forgot, I was trying to trim the selected text, not find the position!

I wouldn't mind it being added!
__________________
Reply With Quote
  #15  
Old 05-23-2007, 09:18 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by xAndrewx View Post
I wouldn't mind it being added!
Me neither
__________________
Reply With Quote
  #16  
Old 05-24-2007, 01:57 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
But getstringkeys is for getting subvariables or variables that start with the parameter...it isn't meant for arrays at all!
__________________
Do it with a DON!
Reply With Quote
  #17  
Old 05-24-2007, 02:39 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
getStringKeys() hasn't been GS2ified, doesn't work with Object references.
PHP Code:
function getArrayKeys(array, key) {
  
temp.0// The array element
  
temp.out 0// The output array

  
for (e: array) {
    if (
e.starts(key)) {
      
out.add(e.substring(key.length()));
    }
  }
  return 
out;

__________________

Last edited by Inverness; 05-24-2007 at 02:53 AM..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.