[Plugin] Hash table

Post your completed addons to share with the community

Post » Sat Apr 27, 2013 12:36 pm

How can I append a hash table. I have two tables one that has the loaded ajax call and another that's the stored table. As I want to check the server every few mins for updates and push them into the stored table.

I have tried to use the merge but that's not giving me the correct results as it overwrites current keys rather than appending them.

Also tried to use set value and ussing itemkeycount to get last root key and set value from loaded hash table but I get \ in the json.
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Sat Apr 27, 2013 5:05 pm

@labithiotis

Reference
How about 2. "Merge new keys from hash table B" ?
B
97
S
22
G
179
Posts: 4,126
Reputation: 104,559

Post » Sat Apr 27, 2013 5:58 pm

I want the keys to extend, in that example only D was added becuase it was new.

I have done it by hacking the json data like so:

[code]
Ajax on "Complete" | DataLoaded | Load hash from JSON string Ajax.LastData

var text appendData = ""

System : dataLoaded.itemcnt("") > 0

System for "" from 0 to DataLoaded.ItemCnt("")-1 | Add DataLoaded.at (str(loopindex) to appendData

       System append =! "" && loopindex < dataLoaded.itemCnt("")-1 | Add "," to appendOrders

System DataAll.itemCnt("") = 0 | System : set appendData to "[" & appendData & "]"

                                 | dataAll Load hash table from JSON string appendData

[/code]
I want to do this :
Table A (Loaded) : [ 1:"A", 2:"B" ]

Table B (All) : [ 1:"X", 2:"Y" ]

Result after merging/appending A with B : [ 1:"A", 2:"B", 3:"X", 4:"Y"]

with the current merge that result is : [ 1:"X", 2:"Y" ] has it has merge the indexes.

Note- the root is blank from my server and I can't change that:
[code]
[
{
   "ID": 129,   
   "X": X
},
{
   "ID": 130,   
   "X": X
},
{
   "ID": 131,   
   "X": X
}
]
[/code]labithiotis2013-04-27 18:04:04
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Sat Apr 27, 2013 6:46 pm

I've tweaked it further because of an issue with additional appends.

B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Sun Apr 28, 2013 1:28 am

@labithiotis

Oh, I understand. Your requirement is so special. I'm afraid that hash table could not support this. You could do this at event sheet, or functionext plugin if you like javascript.rexrainbow2013-04-28 01:28:47
B
97
S
22
G
179
Posts: 4,126
Reputation: 104,559

Post » Tue May 07, 2013 4:31 pm

Hello rexrainbow,

I have a question for you, I,m new with Construct2.

Would it be possible to get JSON data from an outside weather source and parse it with Hash Table?

If yes, do you think that functionality can be supported to a CocoonJS export to an iPhone app?

Thank you!

I'm trying to get an answer for that before investing time and money in my project!

B
4
Posts: 7
Reputation: 464

Post » Tue May 07, 2013 5:30 pm

@claudius139

I'm not sure, I thought cocoonJS could not support AJAX yet. (Maybe I'm wrong) So designer could not get external data from network right now.
B
97
S
22
G
179
Posts: 4,126
Reputation: 104,559

Post » Sun May 12, 2013 12:40 pm

Hey Rex,

What's the best way to sort a hash table by a key/pair. As I wanted to order them by date for example. Just means that when I display them by iterating through the hash their in the correct order already.

Cheers.
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Sun May 12, 2013 5:52 pm

@labithiotis

There is no directly & simple way to sort by key/pair.
A solution is using javascript injected into functionext plugin. Put the hash table on input parameter in json format, sorting in javascript function, return the sorted array (another hash table) in json format.rexrainbow2013-05-12 17:54:06
B
97
S
22
G
179
Posts: 4,126
Reputation: 104,559

Post » Thu Jun 27, 2013 3:09 am

Hello,

Can i have an array as a value to a key? If so how do i iterate through that array?

Thank You.
B
3
Posts: 5
Reputation: 208

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests