arrays

ActionScript 3 Array Casting problem in Flash CS4

I have these Arrays //Array elements are Sprites (Class) in Flash Library var elements:Array = new Array (el1_spr, el2_spr, el3_spr); var container:Array = new Array(); for var (i:uint; allElements.length; i++){ container.push(allElements[i]); var v:Sprite = (allElements[i] as Sprite); addChild(conta...

How to Compare Values in Array

If you have a string of "1,2,3,1,5,7" you can put this in an array or hash table or whatever is deemed best. How do you determine that all value are the same? In the above example it would fail but if you had "1,1,1" that would be true. ...

PHP try-catch blocks: are they able to catch invalid arg types?

Background: Suppose I have the following obviously-incorrect PHP: try{ $vtest = ''; print(array_pop($vtest)); }catch(Exception $exx){} For it to work with array_pop, $vtest should obviously be an array, not a string. Nevertheless, when I run this code the Warning is exhibited. I don't want that, I just want the...

How do I create an array of strings in C?

I am trying to create an array of strings in C. If I use this code: char (*a[2])[14]; a[0]="blah"; a[1]="hmm"; gcc gives me "warning: assignment from incompatible pointer type". What is the correct way to do this? edit: I am curious why this should give a compiler warning since if I do printf(a[1]);, it correctly prints "hmm". ...

Asking for opinion for my MenuTree structure. Which is better, array or delimiter approach?

Which is the better API? I think the latter approach is better because strings are interned. But I'm pining for succintness. Which do you think is better? [Task("Assortment", Author = "好先生", MenuTree = "The>Quick>Brown>Megan")] public partial class Form1 : MycForm, ITaskPlugin { } or this(strings can be interned): [Task("As...

Java: how to convert HashMap<String, Object> to array

Hi, I need to convert a HashMap<String, Object> to an array; could anyone show me how it's done? ...

Is there a specific smarty function to order alphabetically an array?

Hi, I'm using a smarty template for a multi-language website. I got an array of country that is order by country code, which is ok for the english version as country name are in the right order but no ok for other languages (for example United Kingdom stay in the "U" whereas in French it prints "Royaume Uni". Is there a smarty function...

Scope of variable in Javascript problem

var query1 = urlencode($('input[name="searchTerm1"]').val()); //user1 var query2 = urlencode($('input[name="searchTerm2"]').val()); //user1 var rpp = 20; //number of tweets to retrieve out var c=0; var f1=new Array(); var f2=new Array(); var common=new Array(); $.getJSON('http://twitter.com/followers/ids.json?screen_name='+ query1 + ' ...

Initializing reference types outside of a function in Actionscript 2

I have this small class called City that simply holds some information about a city, here it is: class com.weatherwidget.City { var zipCode:String; var forecastText:Array = new Array(5); } When I have an array of cities and I change one of the forecastText of one city it will change that forecastText for all of the cities. Fo...

Php array post values dificulties

Hello, I cant seem to understand why I cant pass any values with the following code: <div class="menu"> Por favor seleccione os conteúdos: <form name="Categorias" action="Elementos_Descritivos.php" method="post"> <?php $Categorias = array ("Nome", "Data", "Cliente", "Observacoes"); foreach( $Categorias as $key => $value){ echo "<di...

How to update the max loop length if the length gets smaller in the loop body?

I have the following array. <cfset ItemHasUsers = arrayNew(1)> <cfloop query="qReadData"> <cfset ItemHasUsers[qReadData.currentrow]["ID"] = qReadData.ID > <cfset ItemHasUsers[qReadData.currentrow]["Asset"] = qReadData.COUNTOFITEMS > </cfloop> I get some records from my database which i put into a table and which manipulate through a...

Is there a function pointer or array of functions in PowerShell?

I would like to do something like this. Index into an array of functions and apply the appropriate function for the desired loop index. for ($i = 0; $i -lt 9; $i++) { $Fields[$i] = $Fields[$i] | $($FunctionTable[$i]) } #F1..F9 are defined functions or rather filter functions $FunctionTable = {F1}, {F2}, ...

What is array literal notation in javascript and when should you use it?

JSLint is giving me this error: Problem at line 11 character 33: Use the array literal notation []. var myArray = new Array(); What is array literal notation and why does it want me to use it instead? It shows here that new Array(); should work fine... is there something I'm missing? ...

Comparing and updating array values in Python

I'm developing a Sirius XM radio desktop player in Python, in which I want the ability to display a table of all the channels and what is currently playing on each of them. This channel data is obtained from their website as a JSON string. I'm looking for the best data structure that would allow the cleanest way to compare and update t...

Implement a function as []

I have an array which really is a function, however i would like to use it as an array. I know i can write these int var { get{return v2;} } public int this[int v] { get { return realArray[v]; } but how do i implement a function that like an array? i would like to do something like public int pal[int i] { get { return i*2; } } But ...

List<Byte> to String, can you help refactor this ( small ) method ?

Hello, We use this small utility method. But we dont like it. Since it's not very crucial ( that work anyway ... ) , we have forget it. But that's ugly, because we have to go through the whole array, only to convert it from Byte[] to byte[]. I'm looking for a way to cast the Byte [] in byte [] without go throu it or for a utility m...

Trimming an array (filled via DBI)

Hello, I'm trying to read data from SQL Server database using Perl and the DBI module. My intention is to read the data and print it into a text file (comma separated). When I do this, I get the result like this: var1,var2,var3 40406,20 ,783 50230,78 ,680 50230,78 ,680 50230,78 ,680 50230,78 ,680 So there is a whitespace between the ...

Checking if an associative array key exists in Javascript

How do I check if a particular key exists in a Javascript associative array? If a key doesn't exist and I try to access it, will it return false? Or throw an error? ...

c# assign 1 dimensional array to 2 dimensional array syntax

I want to do something like: object[] rowOfObjects = GetRow();//filled somewhere else object[,] tableOfObjects = new object[10,10]; tableOfObjects[0] = rowOfObjects; is this somehow possible and what is the syntax? or I need to do this: for (int i = 0; i < rowOfObjects.Length; i++) { tableOfObjects[0,i] = rowOfObjects[i]; } an...

How do I create and access a Perl hash with scalar keys whose values are arrays?

In Perl 5.10, how do I create and access a hash with scalar keys whose values are arrays? #Doing this does not work properly. %someHash= ("0xfff" => ('Blue', 'Red', 'Yellow')); @arr = @fileContents{"0xfff"}; print @arr; When I print the array, the only thing that prints is "ARRAY('randmemAddr')". When I do a foreach loop on @arr, only...