Search Results

Search found 3243 results on 130 pages for 'artwork creation'.

Page 14/130 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Java Compiler Creation Help..Please

    - by Brian
    I need some help with my code here...What we are trying to do is make a compiler that will read a file containing Machine Code and converting it to 100 lines of 4 bits example: this code is the machine code being converting to opcode and operands. I need some help please.. thanks 799 798 198 499 1008 1108 899 909 898 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Everything compiles but when I go and run my Test.java I get the following OutPut: Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1516) at Compiler.FirstPass(Compiler.java:22) at Compiler.compile(Compiler.java:11) at Test.main(Test.java:5) Here is my class Compiler: import java.io.*; import java.io.DataOutputStream; import java.util.NoSuchElementException; import java.util.Scanner; class Compiler{ private int lc = 0; private int dc = 99; public void compile(String filename) { SymbolList symbolTable = FirstPass(filename); SecondPass(symbolTable, filename); } public SymbolList FirstPass(String filename) { File file = new File(filename); SymbolList temp = new SymbolList(); int dc = 99; int lc = 0; try{ Scanner scan = new Scanner(file); String line = scan.nextLine(); String[] linearray = line.split(" "); while(line!=null){ if(!linearray[0].equals("REM")){ if(!this.isInstruction(linearray[0])){ linearray[0]=removeColon(linearray[0]); if(this.isInstruction(linearray[1])){ temp.add(new Symbol(linearray[0], lc, null)); lc++; } else { temp.add(new Symbol(linearray[0], dc, Integer.valueOf((linearr\ ay[2])))); dc--; } } else { if(!linearray[0].equals("REM")) lc++; } } try{ line = scan.nextLine(); } catch(NoSuchElementException e){ line=null; break; } linearray = line.split(" "); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return temp; } public String makeFilename(String filename) { return filename + ".ex"; } public String removeColon(String str) { if(str.charAt(str.length()-1) == ':'){ return str.substring(0, str.length()-1); } else { return str; } } public void SecondPass(SymbolList symbolTable, String filename){ try { int dc = 99; //Open file for reading File file = new File(filename); Scanner scan = new Scanner(file); //Make filename of new executable file String newfile = makeFilename(filename); //Open Output Stream for writing new file. FileOutputStream os = new FileOutputStream(filename); DataOutputStream dos = new DataOutputStream(os); //Read First line. Split line by Spaces into linearray. String line = scan.nextLine(); String[] linearray = line.split(" "); while(scan.hasNextLine()){ if(!linearray[0].equals("REM")){ int inst=0, opcode, loc; if(isInstruction(linearray[0])){ opcode = getOpcode(linearray[0]); loc = symbolTable.searchName(linearray[1]).getMemloc(); inst = (opcode*100)+loc; } else if(!isInstruction(linearray[0])){ if(isInstruction(linearray[1])){ opcode = getOpcode(linearray[1]); if(linearray[1].equals("STOP")) inst=0000; else { loc = symbolTable.searchName(linearray[2]).getMemloc(); inst = (opcode*100)+loc; } } if(linearray[1].equals("DC")) dc--; } System.out.println(inst); dos.writeInt(inst); linearray = line.split(" "); } if(scan.hasNextLine()) { line = scan.nextLine(); } } scan.close(); for(int i = lc; i <= dc; i++) { dos.writeInt(0); } for(int i = dc+1; i<100; i++){ dos.writeInt(symbolTable.searchLocation(i).getValue()); if(i!=99) dos.writeInt(0); } dos.close(); os.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } public int getOpcode(String inst){ int toreturn = -1; if(isInstruction(inst)){ if(inst.equals("STOP")) toreturn=0; if(inst.equals("LD")) toreturn=1; if(inst.equals("STO")) toreturn=2; if(inst.equals("ADD")) toreturn=3; if(inst.equals("SUB")) toreturn=4; if(inst.equals("MPY")) toreturn=5; if(inst.equals("DIV")) toreturn=6; if(inst.equals("IN")) toreturn=7; if(inst.equals("OUT")) toreturn=8; if(inst.equals("B")) toreturn=9; if(inst.equals("BGTR")) toreturn=10; if(inst.equals("BZ")) toreturn=11; return toreturn; } else { return -1; } } public boolean isInstruction(String totest){ boolean toreturn = false; String[] labels = {"IN", "LD", "SUB", "BGTR", "BZ", "OUT", "B", "STO", "STOP", "AD\ D", "MTY", "DIV"}; for(int i = 0; i < 12; i++){ if(totest.equals(labels[i])) toreturn = true; } return toreturn; } } And here is my class Computer: import java.io.*; import java.util.NoSuchElementException; import java.util.Scanner; class Computer{ private Cpu cpu; private Input in; private OutPut out; private Memory mem; public Computer() throws IOException { Memory mem = new Memory(100); Input in = new Input(); OutPut out = new OutPut(); Cpu cpu = new Cpu(); System.out.println(in.getInt()); } public void run() throws IOException { cpu.reset(); cpu.setMDR(mem.read(cpu.getMAR())); cpu.fetch2(); while (!cpu.stop()) { cpu.decode(); if (cpu.OutFlag()) OutPut.display(mem.read(cpu.getMAR())); if (cpu.InFlag()) mem.write(cpu.getMDR(),in.getInt()); if (cpu.StoreFlag()) { mem.write(cpu.getMAR(),in.getInt()); cpu.getMDR(); } else { cpu.setMDR(mem.read(cpu.getMAR())); cpu.execute(); cpu.fetch(); cpu.setMDR(mem.read(cpu.getMAR())); cpu.fetch2(); } } } public void load() { mem.loadMemory(); } } Here is my Memory class: import java.io.*; import java.util.NoSuchElementException; import java.util.Scanner; class Memory{ private MemEl[] memArray; private int size; private int[] mem; public Memory(int s) {size = s; memArray = new MemEl[s]; for(int i = 0; i < s; i++) memArray[i] = new MemEl(); } public void write (int loc,int val) {if (loc >=0 && loc < size) memArray[loc].write(val); else System.out.println("Index Not in Domain"); } public int read (int loc) {return memArray[loc].read(); } public void dump() { for(int i = 0; i < size; i++) if(i%1 == 0) System.out.println(memArray[i].read()); else System.out.print(memArray[i].read()); } public void writeTo(int location, int value) { mem[location] = value; } public int readFrom(int location) { return mem[location]; } public int size() { return mem.length; } public void loadMemory() { this.write(0, 799); this.write(1, 798); this.write(2, 198); this.write(3, 499); this.write(4, 1008); this.write(5, 1108); this.write(6, 899); this.write(7, 909); this.write(8, 898); this.write(9, 0000); } public void loadFromFile(String filename){ try { FileReader fr = new FileReader(filename); BufferedReader br = new BufferedReader(fr); String read=null; int towrite=0; int l=0; do{ try{ read=br.readLine(); towrite = Integer.parseInt(read); }catch(Exception e){ } this.write(l, towrite); l++; }while(l<100); }catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } Here is my Test class: public class Test{ public static void main(String[] args) throws java.io.IOException { Compiler compiler = new Compiler(); compiler.compile("program.txt"); } }

    Read the article

  • Difference in Django object creation call

    - by PhilGo20
    I'd like to know if there's a difference between the following two calls to create an object in Django Animal.objects.create(name="cat", sound="meow") and Animal(name="cat", sound="meow") I see both in test cases and I want to make sure I am not missing something. thanks

    Read the article

  • Delphi fast large bitmap creation (without clearing)

    - by Ritsaert Hornstra
    When using the TBitmap wrapper for a GDI bitmap from the unit Graphics I noticed it will always clear out the bitmap (using a PatBlt call) when setting up a bitmap with SetSize( w, h ). When I copy in the bits later on (see routine below) it seems ScanLine is the fastest possibility and not SetDIBits. function ToBitmap: TBitmap; var i, N, x: Integer; S, D: PAnsiChar; begin Result := TBitmap.Create(); Result.PixelFormat := pf32bit; Result.SetSize( width, height ); S := Src; D := Result.ScanLine[ 0 ]; x := Integer( Result.ScanLine[ 1 ] ) - Integer( D ); N := width * sizeof( longword ); for i := 0 to height - 1 do begin Move( S^, D^, N ); Inc( S, N ); Inc( D, x ); end; end; The bitmaps I need to work with are quite large (150MB of RGB memory). With these iomages it takes 150ms to simply create an empty bitmap and a further 140ms to overwrite it's contents. Is there a way of initializing a TBitmap with the correct size WITHOUT initializing the pixels itself and leaving the memory of the pixels uninitialized (eg dirty)? Or is there another way to do such a thing. I know we could work on the pixels in place but this still leaves the 150ms of unnessesary initializtion of the pixels.

    Read the article

  • List method creation

    - by Jonathan D
    I'm creating a list of my defined objects like so List<clock> cclocks = new List<clocks>(); for each object in the list i'm calling a method moveTime, like so foreach(clock c in cclocks) { c.moveTime(); } is the a way i can write some cleaver thing so i can call cclocks.moveTime(); it would then go though the list doing that method I guess I want to create a collection method? I'm guessing there must be some thing I can do I just don't know what. thanks for your help

    Read the article

  • Client side javascript, creation of several elements and show each asap

    - by Sirius Lampochkin
    Client side javascript code create some elements (about 50-100) in cycle: for (var i = 0; i < list.Length; i++) { var obj = document.createElement("DIV"); obj.innerHTML = "<span class=\"itemId\">" + list[i].Id + "</span><!-- some more simple code --> "; mainObj.appendChild(obj); } There is some problem with browser rendering, for example IE just freeze until he finished the cycle and then shows all elements in one time. Is there a way to show each created element separately and immediately after "appendChild()"?

    Read the article

  • c# delegete creation and activation

    - by aharont
    I have two functions: double fullFingerPrinting(string location1, string location2, int nGrams) double AllSubstrings(string location1, string location2, int nGrams) I want to go in a loop and activate each function in its turn, and after each function I also want to print the name of the function, how can I do that?

    Read the article

  • creation of folders in python

    - by beena shamsudeen
    i want to create folders with the name of a pdf file for eg,abc.if it does not exists,i should create a folder with name abc_1...if abc_1 exists,i shud create abc_2.if both exxists,abc_3 and so on...the scripting is in python..can u help me??

    Read the article

  • dynamic module creation

    - by intuited
    I'd like to dynamically create a module from a dictionary, and I'm wondering if adding an element to sys.modules is really the best way to do this. EG context = { a: 1, b: 2 } import types test_context_module = types.ModuleType('TestContext', 'Module created to provide a context for tests') test_context_module.__dict__.update(context) import sys sys.modules['TestContext'] = test_context_module My immediate goal in this regard is to be able to provide a context for timing test execution: import timeit timeit.Timer('a + b', 'from TestContext import *') It seems that there are other ways to do this, since the Timer constructor takes objects as well as strings. I'm still interested in learning how to do this though, since a) it has other potential applications; and b) I'm not sure exactly how to use objects with the Timer constructor; doing so may prove to be less appropriate than this approach in some circumstances. EDITS/REVELATIONS/PHOOEYS/EUREKAE: I've realized that the example code relating to running timing tests won't actually work, because import * only works at the module level, and the context in which that statement is executed is that of a function in the testit module. In other words, the globals dictionary used when executing that code is that of main, since that's where I was when I wrote the code in the interactive shell. So that rationale for figuring this out is a bit botched, but it's still a valid question. I've discovered that the code run in the first set of examples has the undesirable effect that the namespace in which the newly created module's code executes is that of the module in which it was declared, not its own module. This is like way weird, and could lead to all sorts of unexpected rattlesnakeic sketchiness. So I'm pretty sure that this is not how this sort of thing is meant to be done, if it is in fact something that the Guido doth shine upon. The similar-but-subtly-different case of dynamically loading a module from a file that is not in python's include path is quite easily accomplished using imp.load_source('NewModuleName', 'path/to/module/module_to_load.py'). This does load the module into sys.modules. However this doesn't really answer my question, because really, what if you're running python on an embedded platform with no filesystem? I'm battling a considerable case of information overload at the moment, so I could be mistaken, but there doesn't seem to be anything in the imp module that's capable of this. But the question, essentially, at this point is how to set the global (ie module) context for an object. Maybe I should ask that more specifically? And at a larger scope, how to get Python to do this while shoehorning objects into a given module?

    Read the article

  • XML file creation Using XDocument

    - by Pramodh
    i've a list (List< string) "sampleList" which contains Data1 Data2 Data3... How to create an XML file using XDocument by iterating the items in the list in c sharp. The file structure is like <file> <name="samplee"/> <date=" "/> <info> <data value="Data1"/> <data value="Data2"/> <data value="Data3"/> </info> </file please help me to do this

    Read the article

  • [PHP] - Lowering script memory usage in a "big" file creation

    - by Riccardo
    Hi there people, it looks like I'm facing a typical memory outage problem when using a PHP script. The script, originally developed by another person, serves as an XML sitemap creator, and on large websites uses quite a lot of memory. I thought that the problem was related due to an algorithm holding data in memory until the job was done, but digging into the code I have discovered that the script works in this way: open file in output (will contain XML sitemap entries) in the loop: ---- for each entry to be added in sitemap, do fwrite close file end Although there are no huge arrays or variables being kept in memory, this technique uses a lot of memory. I thought that maybe PHP was buffering under the hood the fwrites and "flushing" data at the end of the script, so I have modified the code to close and open the file every Nth record, but the memory usage is still the same.... I'm debugging the script on my computer and watching memory usage: while script execution runs, memory allocation grows. Is there a particular technique to instruct PHP to free unsed memory, to force flushing buffers if any? Thanks

    Read the article

  • iCalcreator 2.6 event creation sent in an email w/o attachment

    - by Jonas
    G'day everyone, I am currently trying to send meeting invitations to Outlook recipients. After reading several blogs and various literature iCalcreator seems to be the most complete iCalendar PHP class available. And the documentation is just...crazily complete. If creating a iCal .ics file is OK, I can't find a nice way to send it by email to the attendees without having them to double click on an attachment. Just like Google Calendar and Outlook do, I would like to send emails that will automatically show the buttons Accept | Tentative | Decline upon reception without any other user action involved. If anyone ever had to realize that, I would be more than happy to get your feedback/help or even just relevant guidance. Thanks

    Read the article

  • Idiomatic PHP web page creation

    - by GreenMatt
    My PHP experience is rather limited. I've just inherited some stuff that looks odd to me, and I'd like to know if this is a standard way to do things. The page which shows up in the browser location (e.g. www.example.com/example_page) has something like: <? $title = "Page Title"; $meta = "Some metadata"; require("pageheader.inc"); ?> <!-- Content --> Then pageheader.inc has stuff like: <? @$title = ($title) ? $title : ""; @$meta = ($meta) ? $meta : ""; ?> <html> <head> <title><?=$title?></title </head> <!-- and so forth --> Maybe others find this style useful, but it confuses me. I suppose this could be a step toward a rudimentary content management system, but the way it works here I'd think it adds to the processing the server has to do without reducing the load on the web developer enough to make it worth the effort. So, is this a normal way to create pages with PHP? Or should I pull all this in favor of a better approach? Also, I know that "<?" (vs. "<?php" ) is undesirable; I'm just reproducing what is in the code.

    Read the article

  • Partitioning a table in mysql after creation

    - by erik
    I have a table with a bunch of data already in it. I know how to create a partitioned table or alter an already existing partitioned table, but can I add partitions to a table after it has been created, has data in it, without losing the data? The other option is to dump all the data, recreate the table with the partitions and then insert it all back it. Is that the only way? Thanks.

    Read the article

  • castle dynamic proxy creation

    - by ashish.s
    I am implementing a design where my layer would sit between client and server, and whatever objects i get from server, i would wrap it in a transparent proxy and give to the client, that way i can keep a track of what changed in the object, so when saving it back, i would only send changed information. I looked at castle dynamic proxy, linfu, although they can generate a proxy type, but they cant take existing objects and wrap them instead. Wondering if its possible to do with these frameworks, or if there any other frameworks that enable this...

    Read the article

  • Correct (pretty) window redraw during the creation

    - by Coder
    Does anyone know what is a correct way to redraw window during lengthy initialization operations? Say I have HWND with NULL brush, and it does some not so quick child window initialization (Window initialization is not so quick on Vista and 7, especially on netbooks, even with threaded app). With this config window stays black for half a second on slower laptops. But if I supply window color brush, it seems that there are some sort of child controls or something that draws black squares on top of it, which also seems ugly. Even though the controls are created without WS_VISIBLE initially. Oh, the window has the WS_EX_COMPOSITED style, which should do the double buffering to avoid flicker. But it still behaves ugly. Are there any other tricks I've forgotten, missed?

    Read the article

  • How to disable sql creation for JPA entity classes

    - by Samuel
    We have some JPA entity classes which are currently under development and wouldn't want them as part of the testing cycle. We tried commenting out the relevant entity classes in META-INF\persistence.xml but the hbm2ddl reverse engineering tool still seems to generate SQL for those entities. How do I tell my code to ignore these classes? Are there any annotations for these or should I have to comment out the @Entity annotation along with my changes in persistence.xml file.

    Read the article

  • Doctrine-CLI database creation issue.

    - by gokujou
    I have Doctrine setup in my Zend Framework application and I built my schema YAML file. But when I tell Doctrine to build the tables it says it does but it doesn't actually make them. It creates the models, and will create the DB but it will not populate the DB with the tables and throws no errors. Does anyone have a guess or know why this is not working? Thank you.

    Read the article

  • Dynamic creation of VS Project

    - by Adkins
    I have a project where I create WiX (Windows Installer for XML) files, when they are not already present. It is working perfectly. Now I want to expand it to add more functionality. I was wondering if there is a way to create a Visual Studio project programmatically? This project is run as part of our nightly build process, and when a new wix file is needed it is created, but I want to have everything in place when the build is finished so if necessary you can just open the project in Visual Studio and start editing. Am I dreaming outside the realm of possibility or no? Any nudge in the right direction will be greatly appreciated.

    Read the article

  • Minimalist array creation in c#

    - by sipwiz
    I've always wanted to be able to use the line below but the C# compiler won't let me. To me it seems obvious and unambiguos as to what I want. myString.Trim({'[', ']'}); I can acheive my goal using: myString.Trim(new char[]{'[', ']'}); So I don't die wondering is there any other way to do it that is closer to the first approach?

    Read the article

  • python conditional list creation from 2D lists

    - by dls
    Say I've got a list of lists. Say the inner list of three elements in size and looks like this: ['apple', 'fruit', 1.23] The outer list looks like this data = [['apple', 'fruit', 1.23], ['pear', 'fruit', 2.34], ['lettuce', 'vegetable', 3.45]] I want to iterate through the outer list and cull data for a temporary list only in the case that element 1 matches some keyword (aka: 'fruit'). So, if I'm matching fruit, I would end up with this: tempList = [('apple', 1.23), ('pear', 2.34)] This is one way to accomplish this: tempList = [] for i in data: if i[1] == 'fruit': tempList.append(i[0], i[2]) is there some 'Pythonic' way to do this in fewer lines?

    Read the article

  • Default entries on a first time creation for a serialized class

    - by MGSoto
    I have a class I am using for serializing various configuration options for an application I am working on. I'm adding a new property to the class that is a List, and I'd like it to fill this list if it does not exist already in a XML file. My first thought was to check if the list contained zero items, however this is not acceptable because there are times I want to have zero items in the list. In essence I want a file that has been serialized with an older version of the same class to be "upgraded" and have defaults automatically inserted for new properties. How can I do this? For a more visual example of what I'm trying to do, see below: When I deserialize an XML file that contains: <Item1>wtfe</Item1> <Item2>wtfe</Item2> and after I've added a list property it will serialze as: <Item1>wtfe</Item1> <Item2>wtfe</Item2> <Item3/> I want it to serialize as: <Item1>wtfe</Item1> <Item2>wtfe</Item2> <Item3> <DefaultSubItem/ Field="wtfe"> <DefaultSubItem/ Field="wtfe"> </Item3> But allow me to change it to: <Item1>wtfe</Item1> <Item2>wtfe</Item2> <Item3></Item3>

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >