Daily Archives

Articles indexed Sunday December 2 2012

Page 9/13 | < Previous Page | 5 6 7 8 9 10 11 12 13  | Next Page >

  • Getting Started on Isometric Board Game port

    - by Jehosephat
    I have developed a (off-line) board game that I would like to translate to an online/social game in an isometric grid perspective. My background is in .NET web development, so I'm very comfortable with C#, HTML, jQuery/javascript. Still getting my feet wet with HTML5. I have familiarity with Flash, but I haven't worked with it in years. I'm also interested in working with Azure for hosting the back-end. Ultimately I'd like this game to have persistent leaderboard/achievements and therefore be able to log in through FB and Kong and the like. Obviously, I'm not looking for 'here's exactly how to do all of this'. But I would love some opinions on where to start, particularly given my background and goals. Would be happy to share more details if it makes answering easier! Thanks!

    Read the article

  • 2D isometric picking

    - by Bikonja
    I'm trying to implement picking in my isometric 2D game, however, I am failing. First of all, I've searched for a solution and came to several, different equations and even a solution using matrices. I tried implementing every single one, but none of them seem to work for me. The idea is that I have an array of tiles, with each tile having it's x and y coordinates specified (in this simplified example it's by it's position in the array). I'm thinking that the tile (0, 0) should be on the left, (max, 0) on top, (0, max) on the bottom and (max, max) on the right. I came up with this loop for drawing, which googling seems to have verified as the correct solution, as has the rendered scene (ofcourse, it could still be wrong, also, forgive the messy names and stuff, it's just a WIP proof of concept code) // Draw code int col = 0; int row = 0; for (int i = 0; i < nrOfTiles; ++i) { // XOffset and YOffset are currently hardcoded values, but will represent camera offset combined with HUD offset Point tile = IsoToScreen(col, row, TileWidth / 2, TileHeight / 2, XOffset, YOffset); int x = tile.X; int y = tile.Y; spriteBatch.Draw(_tiles[i], new Rectangle(tile.X, tile.Y, TileWidth, TileHeight), Color.White); col++; if (col >= Columns) // Columns is the number of tiles in a single row { col = 0; row++; } } // Get selection overlay location (removed check if selection exists for simplicity sake) Point tile = IsoToScreen(_selectedTile.X, _selectedTile.Y, TileWidth / 2, TileHeight / 2, XOffset, YOffset); spriteBatch.Draw(_selectionTexture, new Rectangle(tile.X, tile.Y, TileWidth, TileHeight), Color.White); // End of draw code public Point IsoToScreen(int isoX, int isoY, int widthHalf, int heightHalf, int xOffset, int yOffset) { Point newPoint = new Point(); newPoint.X = widthHalf * (isoX + isoY) + xOffset; newPoint.Y = heightHalf * (-isoX + isoY) + yOffset; return newPoint; } This code draws the tiles correctly. Now I wanted to do picking to select the tiles. For this, I tried coming up with equations of my own (including reversing the drawing equation) and I tried multiple solutions I found on the internet and none of these solutions worked. Trying out lots of solutions, I came upon one that didn't work, but it seemed like an axis was just inverted. I fiddled around with the equations and somehow managed to get it to actually work (but have no idea why it works), but while it's close, it still doesn't work. I'm not really sure how to describe the behaviour, but it changes the selection at wrong places, while being fairly close (sometimes spot on, sometimes a tile off, I believe never more off than the adjacent tile). This is the code I have for getting which tile coordinates are selected: public Point? ScreenToIso(int screenX, int screenY, int tileHeight, int offsetX, int offsetY) { Point? newPoint = null; int nX = -1; int nY = -1; int tX = screenX - offsetX; int tY = screenY - offsetY; nX = -(tY - tX / 2) / tileHeight; nY = (tY + tX / 2) / tileHeight; newPoint = new Point(nX, nY); return newPoint; } I have no idea why this code is so close, especially considering it doesn't even use the tile width and all my attempts to write an equation myself or use a solution I googled failed. Also, I don't think this code accounts for the area outside the "tile" (the transparent part of the tile image), for which I intend to add a color map, but even if that's true, it's not the problem as the selection sometimes switches on approx 25% or 75% of width or height. I'm thinking I've stumbled upon a wrong path and need to backtrack, but at this point, I'm not sure what to do so I hope someone can shed some light on my error or point me to the right path. It may be worth mentioning that my goal is to not only pick the tile. Each main tile will be divided into 5x5 smaller tiles which won't be drawn seperately from the whole main tile, but they will need to be picked out. I think a color map of a main tile with different colors for different coordinates within the main tile should take care of that though, which would fall within using a color map for the main tile (for the transparent parts of the tile, meaning parts that possibly belong to other tiles).

    Read the article

  • Is there an alternative to SDL 1.3 for a C++ game that should run on iOS and Android?

    - by futlib
    I've used SDL for many desktop games, always as the cross-platform glue for: Creating a window Processing input Rendering images Rendering fonts Playing sounds/music It has never disappointed me at those tasks. But when it comes to graphics, I prefer to work with the OpenGL API directly, even though all of our games are 2D. In the project I'm currently working on, I've made sure to only use the API subset supported by both OpenGL 1.3 and OpenGL 1.0, so making the thing run on Android should be easy, I thought. Turns out there is no official Android or iOS port of SDL yet. However, there's one in SDL 1.3, which is still in development. SDL 1.3 doesn't seem very appealing to me for three reasons: It's been in development for at least 4 years, and I have no idea when it will be done, not to mention stable. It's not ported to as many platforms as SDL 1.2. From what I've seen, it uses OpenGL for drawing, so I suppose the community will move away from directly using OpenGL. So I'm wondering if I should use a different library for our current project - it doesn't matter much if I need to port my existing code from SDL 1.2 to SDL 1.3 or to some other library. We're planning to release on Windows, Mac OS X, Linux, iOS and Android, so good support for these platforms is essential. Is there anything stable that does what I want?

    Read the article

  • WIn API Basic Paint program

    - by Tom Burman
    Just trying to learn a bit of Win API. Im trying to make a basic drawing app, a bit like MS Paint. For the time being im trying to get one function to work which is, when you left click and drag the mouse around the screen a line is drawn behind the mouse. Heres what i have so far, but for some reason: 1) the line starts drawing straight away rather then waiting for the left click 2) the line isn't solid its very dotty. case WM_MOUSEMOVE: { if(MK_LBUTTON){ hdc = GetDC(hwnd); hPen = CreatePen(PS_SOLID,5,RGB(0, 0, 255)); SelectObject(hdc, hPen); int x = LOWORD(lParam); int y = HIWORD(lParam); MoveToEx(hdc,x,y,NULL); LineTo(hdc, LOWORD(lParam), HIWORD(lParam)); ReleaseDC(hwnd,hdc); } else break; } } Thanks for any help!

    Read the article

  • backface culling error (in world space)

    - by acrilige
    I write simple software renderer. In my pipeline i have stage of backface culling. But looks like it has some error (see picture). I perform culling right after world transformation (is it correct?). (i can't insert picture in post coz i don't have enough points, so i just upload it (cube model): http://imageshack.us/photo/my-images/705/bcerror.png/) Vector3F view_dir(0.0f, 0.0f, 1.0f); std::vector<Triangle> to_remove; for (Triangle &t : m_triangles) { Vector4F e1 = t.v2 - t.v1; Vector4F e2 = t.v3 - t.v1; Vector3F normal( e1.y * e2.z - e1.z * e2.y, e1.z * e2.x - e1.x * e2.z, e1.x * e2.y - e1.y * e2.x ); normal.Normalize(); float dot = Dot(view_dir, normal); if (dot <= 0) to_remove.push_back(t); } for (Triangle& t : to_remove) m_triangles.erase(std::remove(m_triangles.begin(), m_triangles.end(), t), m_triangles.end()); Camera sits in origin and points in screen (RH). What is the reason? For better explanation i upload picture with cube rotation screenshots: http://imageshack.us/photo/my-images/842/bcmove.png/ UPDATED: The error occurs only when triangle has non-zero offset from origin UPDATED 2: If i process backface culling in clip space (after transforming all vertices with view and projection matrix), and just check z coordinate of triangle normal - it works perfect... Can i perform culing RIGHT BEFORE view/proj transforms? In this case looks like culling will not depends of projection and it's not right?.. UPDATED 3: I found answer and will post it in two hours - again coz of reputation lack.

    Read the article

  • Shifting from XNA/C# to C++?

    - by Fat_Scout
    For a while now, I've been working with XNA for game design and development (although only for personal use ATM.) Overall, I'm a major fan of XNA itself, and it's overall "feel." However, due to the fact that: XNA seems to have a lack of support (no Metro support, no updates since 2010, etc.) I plan to try and get a job in the game development industry, and due to C++'s dominance, being more familiar with it would be very useful XNA only supports Windows (non-Metro) and Xbox 360, while I am interested in Mac and (to a lesser extent) Linux support. I've been trying to shift over to C++ as my main language. However, I do not want to focus on learning raw DirectX/C++ at this time, so I've been looking for a higher level C++ API (something about the same level as XNA, although something a bit more low-level would be fine) with a feel similar to XNA. So, for someone switching from C#/XNA to C++, what would my best choice(s) be for API's similar to XNA, although unmanaged and running on C++?

    Read the article

  • Android MediaPlayer Won't Play Different Sounds

    - by cYn
    I'm making a simple app that plays a different sound according to its orientation. So if it's placed face down, a sound is played. If placed on its left side, a different sound is played. I'm having a hard time manipulating MediaPlayer correctly. My app runs fine. But it will only play one sound. For example. When I first boot up my app and place my device facing up, a sound will play. If I change its orientation, the sound will pause. But it will not start a different sound in a different orientation. BUT, if I place the device back facing up, it resumes the sound that it paused. I know I'm doing something wrong here, but I can't seem to figure it out the correct structure in using MediaPlayer and the program constantly calling it through onSensorChanged. public class MainActivity extends Activity implements SensorEventListener{ MediaPlayer mpAudioAttention; MediaPlayer mpAudioAssembly; MediaPlayer mpAudioRecall; MediaPlayer mpAudioRetreat; MediaPlayer mpAudioReveille; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sm = (SensorManager) getSystemService(SENSOR_SERVICE); setContentView(R.layout.main); mpAudioAttention = MediaPlayer.create(this, R.raw.attention); mpAudioAssembly = MediaPlayer.create(this, R.raw.assembly); mpAudioRecall = MediaPlayer.create(this, R.raw.recall); mpAudioRetreat = MediaPlayer.create(this, R.raw.retreat); mpAudioReveille = MediaPlayer.create(this, R.raw.reveille); } public void onSensorChanged(SensorEvent event) { synchronized (this) { Log.d(tag, "onSensorChanged: " + event + ", z: " + event.values[0] + ", x: " + event.values[1] + ", y: " + event.values[2]); zViewO.setText("Orientation Z: " + event.values[0]); xViewO.setText("Orientation X: " + event.values[1]); yViewO.setText("Orientation Y: " + event.values[2]); } //face down if (event.values[2] > -11 && event.values[2] < -9){ mpAudioRetreat.start(); } else mpAudioRetreat.pause(); //face up if (event.values[2] < 11 && event.values[2] > 9){ mpAudioReveille.start(); } else mpAudioReveille.pause(); //standing if (event.values[0] > -10 && event.values[0] < -8){ mpAudioAttention.start(); } else mpAudioAttention.pause(); //left sideways if (event.values[1] < 11 && event.values[1] > 9){ mpAudioAssembly.start(); } else mpAudioAssembly.pause(); //right sideways if (event.values[1] > -11 && event.values[1] < -9){ mpAudioRecall.start(); } else mpAudioRecall.pause(); }

    Read the article

  • Jquery Uploader not saving to a folder in the site root

    - by Iain Simpson
    im trying to integrate the Jquery Uploader into my website http://blueimp.github.com/jQuery-File-Upload/ The problem I am having is that I cant seem to get it save the folder I want to to save to. In the UploadHander.php I have the following settings 'script_url' => $this->get_full_url().'/', 'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'./images/machinery/', 'upload_url' => $this->get_full_url().'./images/machinery/', This results in an image uploaded url that looks like this http://domain.com/rcsetch/up/server/php/machinery/image.jpg Other than putting my php files in the root of the website, im not sure how to get it to work, as what I want it to do is upload the files to http://domain.com/images/machinery and not to the create a folder in the directory where all the php files for the uploader are located.

    Read the article

  • When to use certain optimizations such as -fwhole-program and -fprofile-generate with several shared libraries

    - by James
    Probably a simple answer; I get quite confused with the language used in the GCC documentation for some of these flags! Anyway, I have three libraries and a programme which uses all these three. I compile each of my libraries seperately with individual (potentially) different sets of warning flags. However, I compile all three libraries with the same set of optimisation flags. I then compile my main programme linking in these three libraries with its own set of warning flags and the same optimisation flags used during the libraries' compilation. 1) Do I have to compile the libraries with optimisation flags present or can I just use these flags when compiling the final programme and linking to the libraries? If the latter, will it then optimise all or just some (presumably that which is called) of the code in these libraries? 2) I would like to use -fwhole-program -flto -fuse-linker-plugin and the linker plugin gold. At which stage do I compile with these on ... just the final compilation or do these flags need to be present during the compilation of the libraries? 3) Pretty much the same as 2) however with, -fprofile-generate -fprofile-arcs and -fprofile-use. I understand one first runs a programme with generate, and then with use. However, do I have to compile each of the libraries with generate/use etc. or just the final programme? And if it is just the last programme, when I then compeil with -fprofile-use will it also optimise the libraries functionality? Many thanks, James

    Read the article

  • Unknown error when creating packages with pkgbuild

    - by Aeyoun
    I followed several tutorials-which all appeared to say the same thing-on how to create deployable flat-packages (.pkg) using the OS X system provided pkgbuild tool. The packages was always generated just fine. They did, however, not want to be installed. Running the graphical Apple Installer or the command line interface installer aborted the installation early on giving an generic “Unknown error” after prompting for higher permissions. Hours later after closer investigation I discovered that I could not install other packages either. Not even updates and new installations from the OS X App Store. Why could I not install my own nor any other packages? What was going on?

    Read the article

  • wxWidgets - Add items to sizer via DLL

    - by intl
    I have a GUI set up with wxWidgets (C++, MSVC) and part of the functionality is to add elements to the GUI via DLL's. Essentially, I would be passing in a sizer to the DLL which will in turn add the elements based on what is in the DLL. Could someone just point me in the right direction on how to get the DLL set up? I have looked, but don't see anything that's similar to what I'm looking for. The programming of the elements is fine with me, I just need to understand how to structure the DLL programming. Help appreciated.

    Read the article

  • jQuery image loop not displaying any images

    - by user1871097
    I'm trying to create a very basic image gallery in jQuery. The goal is to have 3 images fade in and out in a sequential order. So image 1 is displayed, fades to image 2 etc. then the whole thing loops again. My HTML code so far is as follows: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Slider</title> <style type="text/css"> .slider{ width: 2848px; height: 2136px; overflow: hidden; margin: 30px auto; } .slider img{ width:2848px; height:2136px; display:none; } </style> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script> <script src="Slider2.js"></script> </head> <body onload="Slider2"();> <div class="slider"> <img id="1" src="31.jpg" border="0" alt="city"/> <img id="2" src="2vrtigo2.jpg" border="0" alt="roof"/> <img id="3" src="3.jpg" border="0" alt="sea"/> </div> </body> And the jQuery code looks like this: function Slider2() { var total = $(".slider img").size(); for (i=1; i<=total; i+=1) { $(".slider #"+i).fadeIn(600); $(".slider #"+i).delay(2000).hide; }} A quick syntactical note, I've also tried using i++ in the last argument of the For Loop. The result of this code is a blank, white page. I know some of the HTML is being compiled because the enormous 2848x2136 div creates scroll bars on the browser. If anyone could help me out, that would be greatly appreciated. Obviously I'm relatively new to web programming and would love some insight into why this isn't working. Thanks!

    Read the article

  • char[] and char* compatibility?

    - by Aerovistae
    In essence, will this code work? And before you say "Run it and see!", I just realized my cygwin didn't come with gcc and it's currently 40 minutes away from completing reinstallation. That being said: char* words[1000]; for(int i = 0; i<1000; i++) words[i] = NULL; char buffer[ 1024 ]; //omit code that places "ADD splash\0" into the buffer if(strncmp (buffer, "ADD ", 4){ char* temp = buffer + 4; printf("Adding: %s", temp); int i = 0; while(words[i] != NULL) i++; words[i] = temp; } I'm mostly uncertain about the line char* temp = buffer + 4, and also whether I can assign words[i] in the manner that I am. Am I going to get type errors when I eventually try to compile this in 40 minutes? Also-- if this works, why don't I need to use malloc() on each element of words[]? Why can I say words[i] = temp, instead of needing to allocate memory for words[i] the length of temp?

    Read the article

  • python: creating a list inside a dictionary

    - by user1871081
    I just started using python and I'm trying to create a program that will read a file that looks like this: AAA x 111 AAB x 111 AAA x 112 AAC x 123 ... the file is 50 lines long and I'm trying to make the letters into keys in a dictionary and the numbers lists that correspond with the keys. I want the output to look like this: {AAA: ['111', '112'], AAB: ['111'], AAC: [123], ...} This is what I've tried file = open("filename.txt", "r") readline = file.readline().rstrip() while readline!= "": list = [] list = readline.split(" ") j = list.index("x") k = list[0:j] v = list[p + 1:] d = {} if k in d == False d[k] = [] d[k].append(v) else d[k].append(v) readline = file.readline().rstrip() I keep getting syntax errors on my if statement and I can't figure out what I've done wrong.

    Read the article

  • How to call implemented method of generic enum in Java?

    - by Justin Wiseman
    I am trying pass an enum into a method, iterate over that enums values, and call the method that that enum implements on all of those values. I am getting compiler errors on the part "value.getAlias()". It says "The method getAlias() is undefined for the type E" I have attempted to indicate that E implements the HasAlias interface, but it does not seem to work. Is this possible, and if so, how do I fix the code below to do what I want? The code below is only meant to show my process, it is not my intention to just print the names of the values in an enum, but to demonstate my problem. public interface HasAlias{ String getAlias(); }; public enum Letters implements HasAlias { A("The letter A"), B("The letter B"); private final String alias; public String getAlias(){return alias;} public Letters(String alias) { this.alias = alias; } } public enum Numbers implements HasAlias { ONE("The number one"), TWO("The number two"); private final String alias; public String getAlias(){return alias;} public Letters(String alias) { this.alias = alias; } } public class Identifier { public <E extends Enum<? extends HasAlias>> void identify(Class<E> enumClass) { for(E value : enumClass.getEnumConstants()) { System.out.println(value.getAlias()); } } }

    Read the article

  • MYSQL -Incorrect Syntax

    - by user1854392
    WHILE x > 1 DO SET x = x - 1; SET totalTime = SELECT CONCAT(FLOOR(HOUR(TIMEDIFF(end_time,start_time)) / 24), ' days ', MOD(HOUR(TIMEDIFF(end_time,start_time)), 24), ' hrs ', MINUTE(TIMEDIFF(end_time,start_time)), ' minutes ') AS total_Time I don't see why I am having a syntax error? It is part of a bigger procedure but is pointing to this aas being incorrect Error message: SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT CONCAT(FLOOR(HOUR(TIMEDIFF(end_time,start_time)) / 24,' days',' at line 11 and totalTime is declared as a VARCHAR(50)

    Read the article

  • Converting to async,await using async targeting package

    - by e4rthdog
    I have this: private void BtnCheckClick(object sender, EventArgs e) { var a = txtLot.Text; var b = cmbMcu.SelectedItem.ToString(); var c = cmbLocn.SelectedItem.ToString(); btnCheck.BackColor = Color.Red; var task = Task.Factory.StartNew(() => Dal.GetLotAvailabilityF41021(a, b, c)); task.ContinueWith(t => { btnCheck.BackColor = Color.Transparent; lblDescriptionValue.Text = t.Result.Description; lblItemCodeValue.Text = t.Result.Code; lblQuantityValue.Text = t.Result.AvailableQuantity.ToString(); },TaskScheduler .FromCurrentSynchronizationContext() ); LotFocus(true); } and i followed J. Skeet's advice to move into async,await in my .NET 4.0 app. I converted into this: private async void BtnCheckClick(object sender, EventArgs e) { var a = txtLot.Text; var b = cmbMcu.SelectedItem.ToString(); var c = cmbLocn.SelectedItem.ToString(); btnCheck.BackColor = Color.Red; JDEItemLotAvailability itm = await Task.Factory.StartNew(() => Dal.GetLotAvailabilityF41021(a, b, c)); btnCheck.BackColor = Color.Transparent; lblDescriptionValue.Text = itm.Description; lblItemCodeValue.Text = itm.Code; lblQuantityValue.Text = itm.AvailableQuantity.ToString(); LotFocus(true); } It works fine. What confuses me is that i could do it without using Task but just the method of my Dal. But that means that i must have modified my Dal method, which is something i dont want? I would appreciate if someone would explain to me in "plain" words if what i did is optimal or not and why. Thanks P.s. My dal method public bool CheckLotExistF41021(string _lot, string _mcu, string _locn) { using (OleDbConnection con = new OleDbConnection(this.conString)) { OleDbCommand cmd = new OleDbCommand(); cmd.CommandText = "select lilotn from proddta.f41021 " + "where lilotn = ? and trim(limcu) = ? and lilocn= ?"; cmd.Parameters.AddWithValue("@lotn", _lot); cmd.Parameters.AddWithValue("@mcu", _mcu); cmd.Parameters.AddWithValue("@locn", _locn); cmd.Connection = con; con.Open(); OleDbDataReader rdr = cmd.ExecuteReader(); bool _retval = rdr.HasRows; rdr.Close(); con.Close(); return _retval; } }

    Read the article

  • Combine Search Bar and URL Bar into One (WebView)

    - by Jay Bush
    So I'm in the midst of updating my Web Browser app for iOS devices, from the ground up, and I'm trying to implement some more convenient features. One feature that seems to be really popular now, that I have been getting a lot of requests for, is the combination of a Google Search bar and a URL bar in one, like that of the Chrome application. Below is a screenshot of the Google Chrome app, and as you can see, they've made it so you can either enter in a search query like "apple ipad" and it will return a Google search page of 'Apple iPad', or you can enter in a URL "http://apple.com/ipad/" and it will load that URL. I have looked all over the internet, but all I could find were tutorials on how to Search Google with value of the UITextField. I have a feeling that the best way to do this is to probably make a 'check'. Like if the entered value contains 'http://' 'www.' '.com' or no spaces, then load it as a URL, if not then load it in a Google Search page, and then have the webview load up the Google Search page. If anybody could show me to the right direction, that would be great, or even supplying me with some code would be even greater. :) Thanks! If anyone needs part of the code, just ask.

    Read the article

  • How to Implement Backbone Java Logic Code into Android

    - by lord_sneed
    I wrote a program to work from the console in Eclipse and the terminal window in Linux. I am now transforming it into an Android app and I have the basic functionality of the Android UI done up until the point where it needs to use the logic from the Java file of the program I wrote. All of my inputs from the Java file are currently from the keyboard (from Scanners). My question is: how do I transform this to get it work with the user interaction of the app? The only input would be from the built in NumberPicker. Should I copy and paste the code from the Java program to the activity file in the onCreate method and change all of the input methods (Scanners) to work with the Android input? Or do I create variables in the activity file and pass them to the Java program (in the separate class)? (If so, how would I do that? the Java file starts from the main method: public static void main(String[] args) {) Also, will the print statements I have, System.out.println(...);, translate directly into the Android UI and print on the screen or do I have to modify those?

    Read the article

  • Assembly Language bug with space character

    - by Bobby
    Having a bit of difficulty getting my input to print once a white space character is inputted. So far, i have it to display the uppercase/lowercase of the input but once i enter a string it doesnt read whats after the white space character. any suggestions? EDIT: intel x86 processor and im using EMU8086 org 100h include 'emu8086.inc' printn "Enter string to convert" mov dx,20 call get_string printn mov bx,di mov ah,0eh mov al,[ds+bx] cmp al, 41h cmp al, 5Ah jle ToLower1 cmp al, 61h cmp al, 7ah jle ToUpper1 ToLower1: add al, 20h int 10h jmp stop1 ToUpper1: sub al, 20h int 10h stop1: inc bx mov al,[ds+bx] cmp al, 41h cmp al, 5Ah jle ToLower2 cmp al, 61h cmp al, 7ah jle ToUpper2 ToLower2: add al, 20h int 10h jmp stop2 ToUpper2: sub al, 20h int 10h stop2: inc bx mov al,[ds+bx] cmp al, 41h cmp al, 5Ah jle ToLower3 cmp al, 61h cmp al, 7ah jle ToUpper3 ToLower3: add al, 20h int 10h jmp stop3 ToUpper3: sub al, 20h int 10h stop3: inc bx mov al,[ds+bx] cmp al, 41h cmp al, 5Ah jle ToLower4 cmp al, 61h cmp al, 7ah jle ToUpper4 ToLower4: add al, 20h int 10h jmp stop4 ToUpper4: sub al, 20h int 10h stop4: inc bx mov al,[ds+bx] cmp al, 41h cmp al, 5Ah jle ToLower5 cmp al, 61h cmp al, 7ah jle ToUpper5 ToLower5: add al, 20h int 10h jmp stop5 ToUpper5: sub al, 20h int 10h stop5: printn hlt define_get_string define_print_string end

    Read the article

  • Finding group maxes in SQL join result

    - by Gene
    Two SQL tables. One contestant has many entries: Contestants Entries Id Name Id Contestant_Id Score -- ---- -- ------------- ----- 1 Fred 1 3 100 2 Mary 2 3 22 3 Irving 3 1 888 4 Grizelda 4 4 123 5 1 19 6 3 50 Low score wins. Need to retrieve current best scores of all contestants ordered by score: Best Entries Report Name Entry_Id Score ---- -------- ----- Fred 5 19 Irving 2 22 Grizelda 4 123 I can certainly get this done with many queries. My question is whether there's a way to get the result with one, efficient SQL query. I can almost see how to do it with GROUP BY, but not quite. In case it's relevant, the environment is Rails ActiveRecord and PostgreSQL.

    Read the article

  • Dynamic parameters for XSLT 2.0 group-by

    - by Ophileon
    I got this input <?xml version="1.0" encoding="UTF-8"?> <result> <datapoint poiid="2492" period="2004" value="1240"/> <datapoint poiid="2492" period="2005" value="1290"/> <datapoint poiid="2492" period="2006" value="1280"/> <datapoint poiid="2492" period="2007" value="1320"/> <datapoint poiid="2492" period="2008" value="1330"/> <datapoint poiid="2492" period="2009" value="1340"/> <datapoint poiid="2492" period="2010" value="1340"/> <datapoint poiid="2492" period="2011" value="1335"/> <datapoint poiid="2493" period="2004" value="1120"/> <datapoint poiid="2493" period="2005" value="1120"/> <datapoint poiid="2493" period="2006" value="1100"/> <datapoint poiid="2493" period="2007" value="1100"/> <datapoint poiid="2493" period="2008" value="1100"/> <datapoint poiid="2493" period="2009" value="1110"/> <datapoint poiid="2493" period="2010" value="1105"/> <datapoint poiid="2493" period="2011" value="1105"/> </result> and I use this xslt 2.0 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="result"> <xsl:for-each-group select="datapoint" group-by="@poiid"> <node type="poiid" id="{@poiid}"> <xsl:for-each select="current-group()"> <node type="period" id="{@period}" value="{@value}"/> </xsl:for-each> </node> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> to convert it into <?xml version="1.0" encoding="UTF-8"?> <node type="poiid" id="2492"> <node type="period" id="2004" value="1240"/> <node type="period" id="2005" value="1290"/> <node type="period" id="2006" value="1280"/> <node type="period" id="2007" value="1320"/> <node type="period" id="2008" value="1330"/> <node type="period" id="2009" value="1340"/> <node type="period" id="2010" value="1340"/> <node type="period" id="2011" value="1335"/> </node> <node type="poiid" id="2493"> <node type="period" id="2004" value="1120"/> <node type="period" id="2005" value="1120"/> <node type="period" id="2006" value="1100"/> <node type="period" id="2007" value="1100"/> <node type="period" id="2008" value="1100"/> <node type="period" id="2009" value="1110"/> <node type="period" id="2010" value="1105"/> <node type="period" id="2011" value="1105"/> </node> Works smoothly. Where I got stuck is when I tried to make it more dynamic. The real life input has 6 attributes for each datapoint instead of 3, and the usecase requires the possibility to set the grouping parameters dynamically. I tried using parameters <xsl:param name="k1" select="'poiid'"/> <xsl:param name="k2" select="'period'"/> but passing them to the rest of the xslt is something that I can't get right. The code below doesn't work, but clarifies hopefully, what I'm looking for. <xsl:template match="result"> <xsl:for-each-group select="datapoint" group-by="@{$k1}"> <node type="{$k1}" id="@{$k1}"> <xsl:for-each select="current-group()"> <node type="{$k2}" id="@{$k2}" value="{@value}"/> </xsl:for-each> </node> </xsl:for-each-group> </xsl:template> Any help appreciated..

    Read the article

  • Add User to Database not working

    - by user1850189
    I'm really new to ASP.net and I am currently trying to create a registration page on a site. I was successful in adding a user to the database but I decided to add another feature into the code to check what userID's were available. For example, if a user deleted their account their userID would become available for use again. I'm trying to find the min value and the max value and add or subtract 1 depending on whether it is min or max. I can run the code I have written for this with no errors but the user is not added to the database. Can anyone help me figure out what I'm missing from my code to do this? EDIT Code adds a user to database but it adds the new user at -1 instead. I don't seem to be able to see where the issue is. If (aDataReader2.Read() = False) Then aConnection1 = New OleDbConnection(aConnectionString) aConnection1.Open() aQuery = "Insert Into UserDetails " aQuery = aQuery & "Values ('" & userID & "','" & userFName & "','" & userLName & "','" & userEmail & "','" & userUsername & "','" & userPassword & "')" aCommand = New OleDbCommand(aQuery, aConnection1) aCommand.ExecuteNonQuery() aConnection1.Close() ElseIf (min = 1) Then aConnection2 = New OleDbConnection(aConnectionString) aConnection2.Open() aCommand = New OleDbCommand(aQuery3, aConnection2) aDataReader2 = aCommand.ExecuteReader() userID = max + 1 aQuery = "Insert Into UserDetails " aQuery = aQuery & "Values ('" & userID & "','" & userFName & "','" & userLName & "','" & userEmail & "','" & userUsername & "','" & userPassword & "')" aCommand = New OleDbCommand(aQuery, aConnection2) aCommand.ExecuteNonQuery() aConnection2.Close() Else aConnection3 = New OleDbConnection(aConnectionString) aConnection3.Open() aCommand = New OleDbCommand(aQuery2, aConnection3) aDataReader2 = aCommand.ExecuteReader userID = min - 1 aQuery = "Insert Into UserDetails " aQuery = aQuery & "Values ('" & userID & "','" & userFName & "','" & userLName & "','" & userEmail & "','" & userUsername & "','" & userPassword & "')" aCommand = New OleDbCommand(aQuery, aConnection3) aCommand.ExecuteNonQuery() aConnection3.Close() lblResults.Text = "User Account successfully created" btnCreateUser.Enabled = False End If Here's the code I used to get the max and min values from the database. I'm getting a value of 0 for both of them - when min should be 1 and max should be 5 Dim minID As Integer Dim maxID As Integer aQuery2 = "Select Min(UserID) AS '" & [minID] & "' From UserDetails" aQuery3 = "Select Max(UserID) AS ' " & [maxID] & "' From UserDetails"

    Read the article

  • Contact Form + jQuery validationengine

    - by BigMad
    I created this contact form, inserting jQuery fadeLabel and validationEngine to beautify the form the file index.php / .html (I have not yet figured out which of the two versions put it) scripts are index: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script src="/js/backtop.js"></script> <script src="/js/fadeLabel.js"></script> <script> $(document).ready(function () { $('form .fadeLabel').fadeLabel(); }); </script> <script src="/js/validationEngine-it.js"></script> <script src="/js/validationEngine.js"></script> <script> $(document).ready(function(){ $("#form_box").validationEngine({ ajaxSubmit: true, ajaxSubmitFile: "contact.php", ajaxSubmitMessage: "Thank you, We will contact you soon !", success : false, failure : function() {} }) }); </script> <script src="/js/contactform.js"></script> however this is the part of the form's code <p id="form_success" class="success hide"><strong>Grazie!</strong> Il tuo messaggio è stato inviato con successo.</p> <form id="form_box"> <fieldset> <p><label for="name">Nome*</label><input type="text" id="name" name="name" class="validate[required] fadeLabel" value=""/></p> <p><label for="email">E-mail*</label><input type="email" id="email" name="email" class="validate[required,custom[email]] fadeLabel" value=""/></p> <p><label for="website">Sito web</label><input type="url" id="website" name="website" class="fadeLabel" value=""/></p> <p><label for="message">Messaggio*</label><textarea id="message" name="message" class="validate[required] fadeLabel" cols="30" rows="10" value=""></textarea></p> </fieldset> <p id="form_submit" class="submit"><button class="send">Invia</button> *Campi obbligatori</p> <p id="form_send" class="send hide">Invio in corso&hellip;</p> <p id="form_error" class="submit error hide"><button class="send">Invia</button> Si prega di correggere l'errore e re-inviarlo.</p> </form> This is the contact.php where it receives the data and sends 2 emails (one for me with the data and a thank you to those who contacted me) contact.php: <?php //include variables $my_email = "[email protected]"; $my_site = "adrianogenovese.com"; session_start(); $name = $_POST['name']; $email = $_POST['email']; $website = $_POST['website']; $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; //beginning to email me $to = $my_email; $sbj = "Richiesta Informazioni - $my_site"; $msg = " <html> ... //the body of the email to me ... </html> "; $from = $email; $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n"; $headers .= "From: $from"; mail($to,$sbj,$msg,$headers); //email sent to me //beginning of the email recipient $toClient = $email; $msgClient = " <html> ... //the body of the email recipient ... </html> "; $fromClient = $my_email; $sbjClient = "Grazie $name per aver contattato $my_site "; $headersClient = 'MIME-Version: 1.0' . "\r\n"; $headersClient .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headersClient .= "From: $fromClient"; mail($toClient,$sbjClient,$msgClient,$headersClient); //mail inviata al cliente //order confirmation email //Reset error session_destroy(); exit; ?> this is the contact form jscript contactform.js: $(document).ready(function() { $(".send").click(function(){ $("#form_send").removeClass('hide'); $("#form_submit").addClass('hide'); $("#form_error").addClass('hide'); var name = $("#name").val(); var email = $("#email").val(); var website = $("#website").val(); var message = $("#message").val(); if (name == "" || email == "" ) { $("#form_send").addClass('hide'); $("#form_error").removeClass('hide'); } else { $.ajax({ type: "POST", url: "contatti/contact.php", data: "name=" + name + "&email=" + email + "&message=" + message + "&website=" + website, dataType: "html", success: function(msg) { $("#form_send").addClass('hide').delay(3000).fadeOut(3000); $("#form_success").removeClass('hide'); $("#form_box").addClass('hide').slideUp(2000).fadeOut(); }, error: function() { alert("An unexpected error occurred..."); } }); } }); //end form });//end Dom The jQuery seem to work very well, I wanted to make sure that the page is not of the form updated or go to another page (the only thing that works for now) compensation reflected in the following problems: I always leave the alert of contactform.js Does not send any mail, it to me to recipient I can not do the work properly. delay () .fadeOut / fadeIn and. SlideUp (). FadeOut () so that the sending of this email appears for 3 seconds "$ (" # form_send "). addClass ('hide')" before you do anything else then the form disappears up using some second type slideUp "$ (" # form_box "). addClass ('hide')" by displaying just the "$ (" # form_success "). removeClass ('hide')" in the address bar also appears the form data (e.g. ../index.php?name=test&email=example%40mail.com&website=&message=helloworld)

    Read the article

  • Passing params in rails... Breakthrough in understanding params, aka, the "aha" moment

    - by Brian McDonough
    I have a simple has_many belongs_to relationship and I want to include the parent object for the view of the belongs_to model and I have had some success, but I want it to work better. class Submission < ActiveRecord::Base belongs_to :user belongs_to :contest end class Contest < ActiveRecord::Base belongs_to :user has_many :submissions, :dependent => :destroy end In the case that works, I pass contest_id to submissions by placing it in the url: <%= link_to 'Submit Contest Entry', new_submission_path(:contest_id => @contest.id), :class => 'btn btn-primary btn-large mleft10' %> So that, combined with a hidden_field: <%= f.hidden_field :contest_id %> And a find_contest method in the controller (called with a before_filter): def find_contest #the next line is giving the error (line 76) @contest = Contest.find(params[:submission][:contest_id]) end Makes it work for submissions/new, but how do I add a find to the controller that just works across more than that one page, like if I want to access in show and index. Right now, I get an error: Started GET "/submissions?contest_id=5" for 127.0.0.1 at 2012-12-01 16:01:45 -0800 Processing by SubmissionsController#index as HTML Parameters: {"contest_id"=>"5"} User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 ORDER BY users.created_at DESC LIMIT 1 Completed 500 Internal Server Error in 37ms NoMethodError (undefined method `[]' for nil:NilClass): app/controllers/submissions_controller.rb:76:in `find_contest' [edited] Adding show action for submissions: before_filter :find_contest, :except => [:index, :show, :edit, :update, :destroy] def find_contest @contest = Contest.find(params[:submission][:contest_id]) end def show contest_id = @submission.contest_id @submission = @commentable = Submission.find(params[:id]) @comments = @commentable.comments.order(:created_at).reverse respond_to do |format| format.html # show.html.erb format.json { render :json => @submission } end end

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13  | Next Page >