Search Results

Search found 15239 results on 610 pages for 'array population'.

Page 60/610 | < Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >

  • Good Design for Initialization of Static Array

    - by jplot
    I have a question regarding good design in C++. I have a class A, and all objects of this class use an integer array of constant values (they should share the same array, as their values are constant). The array needs to be computed (just once) before any object A. I thought about having another class B which contains the integer array as a static member, an init() method which would fill this array according to some formula and a static boolean flag initialized (if this variable if true then the init() method would do nothing), but I'm not sure this is the best way to solve my design issue. So my question is, what would be a good design/way to accomplish this ? Thanks in advance.

    Read the article

  • Cannot create an array of LinkedLists in Java...?

    - by kchau
    I'm working on a sparse matrix class that needs to use an array of LinkedLists to store the values of a matrix. Each element of the array (i.e. each LinkedList) represents a row of the matrix. And, each element in the LinkedLists represents a column and the stored value. In my class, I have a declaration of the array as: private LinkedList<IntegerNode>[] myMatrix; And, in my constructor for the SparseMatrix, I try to define: myMatrix = new LinkedList<IntegerNode>[numRows]; The error I end up getting is "Cannot create a generic array of LinkedList<IntegerNode>." So, I have two issues with this, 1) What am I doing wrong, and 2) Why is the type acceptable in the declaration for the array if it can't be created? Edit: IntegerNode is a class that I have created. And, all of my class files are packaged together.

    Read the article

  • PHP - Get values from Array

    - by danit
    I am trying to get a record from a database using an sql lookup (sql1). This then returns as an array which is fine, but I need to use part of the array for my next stage. $opt=get_records_sql($sql1); //Diags for SQL content print_object($opt); $n = count($opt); if (empty($opt)) { echo 'No options selected'; } else { $optno = $opt["subjectid"]; // Diags of $optno echo '<br>$optno = '.$optno; As you can see, I tried to use this: $opt["subjectid"] as subjectid is the fieldname that I am trying to access and I was under the impression that this was correct for accessing an array, but I get the following error: Notice: Undefined index: subjectid Array contents: Array ( [1] => stdClass Object ( [uname] => JHollands06 [tutor] => M LSt [subjectid] => 1 [year] => 2010 [optid] => 1 ) )

    Read the article

  • Pass a JSON array to a WCF web service

    - by Tawani
    I am trying to pass a JSON array to a WCF service. But it doesn't seem to work. I actually pulled an array [GetStudents] out the service and sent the exact same array back to the service [SaveStudents] and nothing (empty array) was received. The JSON array is of the format: [ {"Name":"John","Age":12}, {"Name":"Jane","Age":11}, {"Name":"Bill","Age":12} ] And the contracts are of the following format: //Contracts [DataContract] public class Student{ [DataMember]public string Name { get; set; } [DataMember]public int Age{ get; set; } } [CollectionDataContract(Namespace = "")] public class Students : List<Student> { [DataMember]public Endorsements() { } [DataMember]public Endorsements(IEnumerable<Student> source) : base(source) { } } //Operations public Students GetStudents() { var result = new Students(); result.Add(new Student(){Name="John",12}); result.Add(new Student(){Name="Jane",11}); result.Add(new Student(){Name="Bill",12}); return result; } //Operations public void SaveStudents(Students list) { Console.WriteLine(list.Count); //It always returns zero } It there a particular way to send an array to a WCF REST service?

    Read the article

  • GLSL compile error when accessing an array with compile-time constant index

    - by Benlitz
    I have this shader that works well on my computer (using an ATI HD 5700). I have a loop iterating between two constant values, which is, afaik, acceptable in a glsl shader. I write stuff in two arrays in this loop. #define NB_POINT_LIGHT 2 ... varying vec3 vVertToLight[NB_POINT_LIGHT]; varying vec3 vVertToLightWS[NB_POINT_LIGHT]; ... void main() { ... for (int i = 0; i < NB_POINT_LIGHT; ++i) { if (bPointLightUse[i]) { vVertToLight[i] = ConvertToTangentSpace(ShPointLightData[i].Position - WorldPos.xyz); vVertToLightWS[i] = ShPointLightData[i].Position - WorldPos.xyz; } } ... } I tried my program on another computer equipped with an nVidia GTX 560 Ti, and it fails to compile my shader. I get the following errors (94 and 95 are the lines of the two affectations) when calling glLinkProgram: Vertex info ----------- 0(94) : error C5025: lvalue in assignment too complex 0(95) : error C5025: lvalue in assignment too complex I think my code is valid, I don't know if this comes from a compiler bug, a conversion of my shader to another format from the compiler (nvidia looks to convert it to CG), or if I just missed something. I already tried to remove the if (bPointLightUse[i]) statement and I still have the same error. However, if I just write this: vVertToLight[0] = ConvertToTangentSpace(ShPointLightData[0].Position - WorldPos.xyz); vVertToLightWS[0] = ShPointLightData[0].Position - WorldPos.xyz; vVertToLight[1] = ConvertToTangentSpace(ShPointLightData[1].Position - WorldPos.xyz); vVertToLightWS[1] = ShPointLightData[1].Position - WorldPos.xyz; Then I don't have the error anymore, but it's really unconvenient so I would prefer to keep something loop-based. Here is the more detailled config that works: Vendor: ATI Technologies Inc. Renderer: ATI Radeon HD 5700 Series Version: 4.1.10750 Compatibility Profile Context Shading Language version: 4.10 And here is the more detailed config that doesn't work (should also be compatibility profile, although not indicated): Vendor: NVIDIA Corporation Renderer: GeForce GTX 560 Ti/PCI/SSE2 Version: 4.1.0 Shading Language version: 4.10 NVIDIA via Cg compiler

    Read the article

  • Table Decorators on Zend Framework Form

    - by ulduz114
    hello i created a form that it decorates as table form its my code for decorates $this->setElementDecorators(array( 'ViewHelper', 'Errors' array(array('data'=>'HtmlTag'), array('tag'=>'td','class'=>'element')), array('Label',array('tag'=>'td')), array(array('row'=>'HtmlTag'),array('tag'=>'tr')), )); $this->setDecorators(array( 'FormElements', array('HtmlTag',array('tag'=>'table')), 'Form' )); it works correctly, now i wana errors message decorates too what do i change my code?

    Read the article

  • HP DL380 RAID5 Mistake

    - by Eddy
    I had drives fail in both logical drives on a server. When I replaced failed 146GB drive in Raid 5 array with four (4) 146GB drives. On reboot the Smart Array controller asked if I wanted to accept data loss. Guess mistake to choose yes. Can't seem to find a way to get system to repair RAID5 but it seems to want to just create a new partition. Is there anyway I can go back and get the system to restore the data from other three drives now that I said accept data loss?

    Read the article

  • Sparse matrices / arrays in Java

    - by DanM
    I'm working on a project, written in Java, which requires that I build a very large 2-D sparse array. Very sparse, if that makes a difference. Anyway: the most crucial aspect for this application is efficency in terms of time (assume loads of memory, though not nearly so unlimited as to allow me to use a standard 2-D array -- the key range is in the billions in both dimensions). Out of the kajillion cells in the array, there will be several hundred thousand cells which contain an object. I need to be able to modify cell contents VERY quickly. Anyway: Does anyone know a particularly good library for this purpose? It would have to be Berkeley, LGPL or similar license (no GPL, as the product can't be entirely open-sourced). Or if there's just a very simple way to make a homebrew sparse array object, that'd be fine too. I'm considering MTJ, but haven't heard any opinions on its quality. Thanks!! -Dan

    Read the article

  • PHP function generate UL LI

    - by apis17
    hi.. i'm referring this address for function olLiTree http://stackoverflow.com/questions/753853/php-function-that-creates-a-nested-ul-li i have this array $tree = array("A"=array("B"=array("C"="C","D"="D"),"E"=array("F"="F","G"="G"))); but not able to use this function function olLiTree($tree) { echo '<ul>'; foreach($tree as $item) { if (is_array($item)) { olLiTree($item); } else { echo '<li>', $item, '</li>'; } } echo '</ul>'; } to generate <ul> <li>A</li> <li>B <ul> <li>C</li> <li>D</li> </ul> </li> <li>E <ul> <li>F </li> </ul> </li> <ul> <li>G</li> </ul> </ul> can anybody help me to fix this? thanks..

    Read the article

  • PHP Stop Word List

    - by Dom Hodgson
    I'm playing about with a stop words within my code I have an array full of words that I'd like to check, and an array of words I want to check against. At the moment I'm looping through the array one at at a time and removing the word if its in_array vs the stop word list but I wonder if there's a better way of doing it, I've looked at array_diff and such however if I have multiple stop words in the first array, array_diff only appears to remove the first occurrence. The focus is on speed and memory usage but speed more so. Thanks

    Read the article

  • using nested arrays by php http_build_query() and recieve them in flash AS3

    - by Mahmoud
    hi, i am having this hard time figuring what is needed to do, i am using URLVariables to send/recieve values between flash and PHP the problem is, i am unable to access nested arrays ( array inside an array ) with flash heres an example: $dgresult = array("total" = $results); echo http_build_query($dgresult,"flf_"); in flash, all i need to do is to use: var variables:URLVariables = new URLVariables(e.target.data); then i can access it with : variables.total the problem now is when i have nested arrays: $dgresult = array("total" = $results); array_push($dgresult,$another_array); http_build_query($dgresult,"flf_"); i can still access variables.total but what about anything that has flf_ ? how is that possible?

    Read the article

  • What is the structure of network managers system-connections files?

    - by Oyks Livede
    could anyone list the complete structure of the configuration files, which network manager stores for known networks in /etc/NetworkManager/system-connections for known networks? Sample (filename askUbuntu): [connection] id=askUbuntu uuid=81255b2e-bdf1-4bdb-b6f5-b94ef16550cd type=802-11-wireless [802-11-wireless] ssid=askUbuntu mode=infrastructure mac-address=00:08:CA:E6:76:D8 [ipv6] method=auto [ipv4] method=auto I would like to create some of them by my own using a script. However, before doing so I would like to know every possible option. Furthermore, this structure seems somehow to resemble the information you can get using the dbus for active connections. dbus-send --system --print-reply \ --dest=org.freedesktop.NetworkManager \ "$active_setting_path" \ # /org/freedesktop/NetworkManager/Settings/2 org.freedesktop.NetworkManager.Settings.Connection.GetSettings Will tell you: array [ dict entry( string "802-11-wireless" array [ dict entry( string "ssid" variant array of bytes "askUbuntu" ) dict entry( string "mode" variant string "infrastructure" ) dict entry( string "mac-address" variant array of bytes [ 00 08 ca e6 76 d8 ] ) dict entry( string "seen-bssids" variant array [ string "02:1A:11:F8:C5:64" string "02:1A:11:FD:1F:EA" ] ) ] ) dict entry( string "connection" array [ dict entry( string "id" variant string "askUbuntu" ) dict entry( string "uuid" variant string "81255b2e-bdf1-4bdb-b6f5-b94ef16550cd" ) dict entry( string "timestamp" variant uint64 1383146668 ) dict entry( string "type" variant string "802-11-wireless" ) ] ) dict entry( string "ipv4" array [ dict entry( string "addresses" variant array [ ] ) dict entry( string "dns" variant array [ ] ) dict entry( string "method" variant string "auto" ) dict entry( string "routes" variant array [ ] ) ] ) dict entry( string "ipv6" array [ dict entry( string "addresses" variant array [ ] ) dict entry( string "dns" variant array [ ] ) dict entry( string "method" variant string "auto" ) dict entry( string "routes" variant array [ ] ) ] ) ] I can create new setting files using the dbus (AddSettings() in /org/freedesktop/NetworkManager/Settings) passing this type of input, so explaining me this structure and telling me all possible options will also help. Afaik, this is a Dictionary{String, Dictionary{String, Variant}}. Will there be any difference creating config files directly or using the dbus?

    Read the article

  • Sorting Arrays by More the One Value, and Prioritizing the Sort based on Column data.

    - by Mark Tomlin
    I'm looking for a way to sort an array (we call this a row), with an array of values (that I'll call columns). Each row has columns that must be sorted based on the priority of: timetime, lapcount & timestamp. Each column cotains this information: split1, split2, split3, laptime, lapcount, timestamp. laptime if in hundredths of a second. (1:23.45 or 1 Minute, 23 Seconds & 45 Hundredths is 8345.) Lapcount is a simple unsigned tiny int, or unsigned char. timestamp is unix epoch. The lowest laptime should be at the get a better standing in this sort. Should two peoples laptimes equal, then timestamp will be used to give the better standing in this sort. Should two peoples timestamp equal, then the person with less of a lapcount get's the better standing in this sort. By better standing, I mean closer to the top of the array, closer to the index of zero where it a numerical array. I think the array sorting functions built into php can do this with a callback, I was wondering what the best approch was for a weighted sort like this would be.

    Read the article

  • Array Recursion

    - by GeeYouAreYou
    I've got an assignment I can't figure out, any pointers will be much appreciated, it goes like so: There's a series of light bulbs represented as an array of true/false, there's a switch for every light bulb, by clicking it for any light bulb, you toggle it as well as 2 adjacent ones (1 from left & another 1 from right; if clicked switch's bulb on edge -- only 1 adjacent toggled of course). What is needed to accomplish is a method that accepts an array of a series of turned on/off light bulbs and another one representing another state of supposedly the 1st array after some switches have been clicked..! So recursion must be used to find out whether there's a combination of switch clicks that will transform array 1 to array 2. Here's the signature of the method: public static boolean disco(boolean[] init, boolean[] target) Will return true if array init can be transformed to target, false otherwise. Method must be static and not use any other static and global variables, only local. Example: boolean[] init = {true, false, true, false, true, false}; boolean[] target = {false, true, false, true, false, true}; For above 2 arrays, disco(init, target) will return true because toggling the 1st and 4th bulbs would yield the target state (remember adjacent bulbs being toggled as well). Any help much appreciated..!!

    Read the article

  • Issue with javascript array object

    - by ezhil
    I have the below JSON response. I am using $.getJSON method to loads JSON data and using callback function to do some manipulation by checking whether it is array as below. { "r": [{ "IsDefault": false, "re": { "Name": "Depo" }, "Valid": "Oct8, 2013", "Clg": [{ "Name": "james", "Rate": 0.05 }, { "Name": "Jack", "Rate": 0.55 }, { "Name": "Mcd", "Rate": 0.01, }], }, { "IsDefault": false, "re": { "Name": "Depo" }, "Valid": "Oct8, 2013", "Clg": [{ "Name": "james", "Rate": 0.05 }, { "Name": "Jack", "Rate": 0.55 }, { "Name": "Mcd", "Rate": 0.01, }], }, { "IsDefault": false, "re": { "Name": "Depo" }, "Valid": "Oct8, 2013", "Clg": [{ "Name": "james", "Rate": 0.05 }, { "Name": "Jack", "Rate": 0.55 }, { "Name": "Mcd", "Rate": 0.01, }], }] } I am passing the json responses on both loadFromJson1 and loadFromJson2 function as "input" as parameter as below. var tablesResult = loadFromJson1(resultstest.r[0].Clg); loadFromJson1 = function (input) { if (_.isArray(input)) { alert("loadFromJson1: Inside array function"); var collection = new CompeCollection(); _.each(input, function (modelData) { collection.add(loadFromJson1(modelData)); }); return collection; } return new CompeModel({ compeRates: loadFromJson2(input), compName: input.Name }); }; loadFromJson2 = function (input) // here is the problem, the 'input' is not an array object so it is not going to IF condition of the isArray method. { if (_.isArray(input)) { alert("loadFromJson2: Inside array function"); //alert is not coming here though it is an array var rcollect = new rateCollection(); _.each(input, function (modelData) { rcollect.add(modelData); }); return rcollect; } }; The above code i am passing json responses for both loadFromJson1 and loadFromJson2 function as "input". isArray is getting true on only loadFromJson1 function and giving alert inside the if condition but not coming in loadFromJson2 function though i am passing the same parameter. can anyone tell me why loadFromJson2 function is not getting the alert inside if condition though i pass array object?

    Read the article

  • PHP Hashtable array optimisation.

    - by hiprakhar
    I made a PHP app which was taking about ~0.0070sec for execution. Now, I added a hashtable array with about 2000 values. Suddenly the time for execution has gone up to ~0.0700 secs. Almost 10 times the previous value. I tried commenting out the part where I was searching inside the hashtable array (but array was still left defined). Still, the execution time remains about ~0.0500secs. Array is something like: $subjectinfo = array( 'TPT753' => 'Industrial Training', 'TPT801' => 'High Polymeric Engineering', 'TPT802' => 'Corrosion Engineering', 'TPT803' => 'Decorative ,Industrial And High Performance Coatings', 'TPT851' => 'Project'); Is there any way to optimize this part? I cannot use Database as I am running this app on Google app engine which is still not supporting JDO database for php. Some more code from the app: function getsubjectinfo($name) { $subjectinfo = array( 'TPT753' => 'Industrial Training', 'TPT801' => 'High Polymeric Engineering', 'TPT802' => 'Corrosion Engineering', 'TPT803' => 'Decorative ,Industrial And High Performance Coatings', 'TPT851' => 'Project'); $name = str_replace("-", "", $name); $name = str_replace(" ", "", $name); if (isset($subjectinfo["$name"])) return "(".$subjectinfo["$name"].")"; else return ""; } Then I am using the following statement 2-3 times in the app: echo $key." ".$this->getsubjectinfo($key)

    Read the article

  • SlimDX Texture2D from DataRectangle array

    - by Rebekah Bryant
    I'm totally new to DirectX. I'm using SlimDX to create a texture consisting of 13046 DataRectangles. Here's my code. It's breaking on the Texture2D constructor with "E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)." inParms is just a struct containing handle to a Panel. public Renderer(Parameters inParms, ref DataRectangle[] inShapes) { Texture2DDescription description = new Texture2DDescription() { Width = 500, Height = 500, MipLevels = 1, ArraySize = inShapes.Length, Format = Format.R32G32B32_Float, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None }; SwapChainDescription chainDescription = new SwapChainDescription() { BufferCount = 1, IsWindowed = true, Usage = Usage.RenderTargetOutput, ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm), SampleDescription = new SampleDescription(1, 0), Flags = SwapChainFlags.None, OutputHandle = inParms.Handle, SwapEffect = SwapEffect.Discard }; Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, chainDescription, out mDevice, out mSwapChain); Texture2D texture = new Texture2D(Device, description, inShapes); } EDIT: Running with the Debug flag set, I got: D3D11 ERROR: ID3D11Device::CreateTexture2D: The format (0x6, R32G32B32_FLOAT) cannot be bound as a RenderTarget, or cast to a format that could be bound as a RenderTarget. This is because the current graphics implementation does not even support this Format. Therefore this format does not support D3D11_BIND_RENDER_TARGET. Use CheckFormatSupport to check Format support. [ STATE_CREATION ERROR #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT] D3D11 ERROR: ID3D11Device::CreateTexture2D: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #104: CREATETEXTURE2D_INVALIDARG_RETURN]

    Read the article

  • Is '@' Error Suppression a Valid Technique for Testing for an Optional Array Key?

    - by MikeSchinkel
    Rarst and I were debating offline about the use of the '@' error suppression operator in PHP, specifically for use to test for existence of "optional" array keys, i.e. array keys that are being used as a switch here a their lack of existence in the array is functionally equivalent to the array having the key with a value equaling false. Here is pseudo-code for this scenario: function do_something( $args = array() ) { if ( @$args['switch'] ) { // Do something with this switch } // continue on... } vs. this approach: function do_something( $args = array() ) { if ( ! empty( $args['switch'] ) && $args['switch'] ) { // Do something with this switch } // continue on... } Of course in most use-cases, suppressing errors would not be A Good Thing(tm). However in this use-case where an array is passed with an optional element, it seems to me that it is actually a very good technique but I could be wrong and would like to hear other's opinions on the subject before I make up my mind. I do know that there are alleged performance hits for using the former approach but I'd like to know how they compare with the alternative and if they performance hits really matter in real world scenarios? P.S. I decided to post this because, after debating this offline with Rarst, he asked a more general question here on Programmers but didn't actually give a detailed example of the specific use-case we were debating. And since I'm pretty sure he'll want to use the out-of-context answers on that other question as justification for why the above is "bad" I decided I needed to get opinions on this specific use-case.

    Read the article

  • Rubik's cube array rotation

    - by Ace
    I'm about to make a 3D Rubik's cube based game in Flash AS3 and Away3d. I don't really know how to manage the 2D arrays of the Rubik's cube. For example, how do I rotate the corresponding arrays if I rotate a side, or just rotate a middle part? In this stage I also don't know how to rotate those smaller cube parts all together if a side is rotating. First I was thinking of "groups" ( like in sketchup or 3ds max, blender), but that would be tricky, because the group components would change every time. So I was thinking of just rotating each individual piece along a global axis. However, I just know the Away3d functions to rotate the cube of his local X , Y or Z axis, but how to rotate in global axis? Does anyone know of a algorithm for doing these types of rotations?

    Read the article

  • Filling array with numbers from given range so that sum of adjacent numbers is square number

    - by REACHUS
    Problem: Fill all the cells using distinct numbers from <1,25 set, so that sum of two adjacent cells is a square number. (source: http://grymat.im.pwr.wroc.pl/etap1/zad1etp1213.pdf; numbers 20 and 13 have been given) I've already solved this problem analytically and now I would like to approach it using an algorithm. I would like to know how should I approach these kind of problems in general (not a solution, just a point for me to start).

    Read the article

  • Returning searched results in an array in Java without ArrayList

    - by Crystal
    I started down this path of implementing a simple search in an array for a hw assignment without knowing we could use ArrayList. I realized it had some bugs in it and figured I'd still try to know what my bug is before using ArrayList. I basically have a class where I can add, remove, or search from an array. public class AcmeLoanManager { public void addLoan(Loan h) { int loanId = h.getLoanId(); loanArray[loanId - 1] = h; } public Loan[] getAllLoans() { return loanArray; } public Loan[] findLoans(Person p) { //Loan[] searchedLoanArray = new Loan[10]; // create new array to hold searched values searchedLoanArray = this.getAllLoans(); // fill new array with all values // Looks through only valid array values, and if Person p does not match using Person.equals() // sets that value to null. for (int i = 0; i < searchedLoanArray.length; i++) { if (searchedLoanArray[i] != null) { if (!(searchedLoanArray[i].getClient().equals(p))) { searchedLoanArray[i] = null; } } } return searchedLoanArray; } public void removeLoan(int loanId) { loanArray[loanId - 1] = null; } private Loan[] loanArray = new Loan[10]; private Loan[] searchedLoanArray = new Loan[10]; // separate array to hold values returned from search } When testing this, I thought it worked, but I think I am overwriting my member variable after I do a search. I initially thought that I could create a new Loan[] in the method and return that, but that didn't seem to work. Then I thought I could have two arrays. One that would not change, and the other just for the searched values. But I think I am not understanding something, like shallow vs deep copying???....

    Read the article

  • PHP: How to copy elements from an associative array and place them at the beginning of the array?

    - by Andrew
    I have an array of countries that I will be using in a select menu: array( [0] => " -- Select -- " [1] => "Afghanistan" [3] => "Albania" [4] => "Algeria" [39] => "Canada" [47] => "USA" ) //etc... I want to copy create copies of the Canada and USA entries and place them at the front of my array. So the array should end up looking like this: array( [0] => " -- Select -- " [47] => "USA" [39] => "Canada" [1] => "Afghanistan" [3] => "Albania" [4] => "Algeria" [39] => "Canada" [47] => "USA" ) //etc... The array keys correspond to their ID in the database, so I can't change the keys. How can I achieve this?

    Read the article

  • Setting the values of a struct array from JS to GLSL

    - by mikidelux
    I've been trying to make a structure that will contain all the lights of my WebGL app, and I'm having troubles setting up it's values from JS. The structure is as follows: struct Light { vec4 position; vec4 ambient; vec4 diffuse; vec4 specular; vec3 spotDirection; float spotCutOff; float constantAttenuation; float linearAttenuation; float quadraticAttenuation; float spotExponent; float spotLightCosCutOff; }; uniform Light lights[numLights]; After testing LOTS of things I made it work but I'm not happy with the code I wrote: program.uniform.lights = []; program.uniform.lights.push({ position: "", diffuse: "", specular: "", ambient: "", spotDirection: "", spotCutOff: "", constantAttenuation: "", linearAttenuation: "", quadraticAttenuation: "", spotExponent: "", spotLightCosCutOff: "" }); program.uniform.lights[0].position = gl.getUniformLocation(program, "lights[0].position"); program.uniform.lights[0].diffuse = gl.getUniformLocation(program, "lights[0].diffuse"); program.uniform.lights[0].specular = gl.getUniformLocation(program, "lights[0].specular"); program.uniform.lights[0].ambient = gl.getUniformLocation(program, "lights[0].ambient"); ... and so on I'm sorry for making you look at this code, I know it's horrible but I can't find a better way. Is there a standard or recommended way of doing this properly? Can anyone enlighten me?

    Read the article

  • Problem with writeToFile with array of NSDictionary objects

    - by Ken
    I'm trying to write an array of NSDictionary objects to a .plist file on the iPhone (OS 3.0). (They are actually NSCFDictionary objects when I call the [object class] method). My problem is that it won't write to file. If I set the array to "nil" it at least creates the empty plist file but won't do it if I have these objects in the array. My array is a parsed response from a JSON HTTP request and looks like this: { "title" = "A Movie"; "time_length" = "3:22"; }, { "title" = "Another Movie"; "time_length" = "1:40"; }, { "title" = "A Third Movie"; "time_length" = "2:10"; } The code to create the file is: [array writeToFile:[self dataFilePath] atomically:YES]; - (NSString *)dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:@"data.plist"]; } Could the NCSFDictionary class of the objects in my array be preventing me from writing to file? Thanks for your help.

    Read the article

  • array or list into Oracle using cfprocparam

    - by Travis
    I have a list of values I want to insert into a table via a stored procedure. I figured I would pass an array to oracle and loop through the array but I don't see how to pass an array into Oracle. I'd pass a list but I don't see how to work with the list to turn it into an array using PL/SQL (I'm fairly new to PL/SQL). Am I approaching this the wrong way? Using Oracle 9i and CF8. TIA! EDIT Perhaps I'm thinking about this the wrong way? I'm sure I'm not doing anything new here... I figured I'd convert the list to an associative array then loop the array because Oracle doesn't seem to work well with lists (in my limited observation). I'm trying to add a product, then add records for the management team. -- product table productName = 'foo' productDescription = 'bar' ... ... etc -- The managementteam table just has the id of the product and id of the users selected from a drop down. The user IDs are passed in via a list like "1,3,6,20" How should I go about adding the records to the management team table?

    Read the article

< Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >