Search Results

Search found 15210 results on 609 pages for 'technical writing'.

Page 38/609 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • writing an Dynamic query in sqlserver

    - by prince23
    hi, DECLARE @sqlCommand varchar(1000) DECLARE @columnList varchar(75) DECLARE @city varchar(75) DECLARE @region varchar(75) SET @columnList = 'first_name, last_name, city' SET @city = '''London''' SET @region = '''South''' SET @sqlCommand = 'SELECT ' + @columnList + ' FROM dbo.employee WHERE City = ' + @city and 'region = '+@region --and 'region = '+@region print(@sqlCommand) EXEC (@sqlCommand) when i run this command i get an error Msg 156, Level 15, State 1, Line 8 Incorrect syntax near the keyword 'and'. and help would great thank you

    Read the article

  • Reading and writing C++ vector to a file

    - by JB
    For some graphics work I need to read in a large amount of data as quickly as possible and would ideally like to directly read and write the data structures to disk. Basically I have a load of 3d models in various file formats which take too long to load so I want to write them out in their "prepared" format as a cache that will load much faster on subsequent runs of the program. Is it safe to do it like this? My worries are around directly reading into the data of the vector? I've removed error checking, hard coded 4 as the size of the int and so on so that i can give a short working example, I know it's bad code, my question really is if it is safe in c++ to read a whole array of structures directly into a vector like this? I believe it to be so, but c++ has so many traps and undefined behavour when you start going low level and dealing directly with raw memory like this. I realise that number formats and sizes may change across platforms and compilers but this will only even be read and written by the same compiler program to cache data that may be needed on a later run of the same program. #include <fstream> #include <vector> using namespace std; struct Vertex { float x, y, z; }; typedef vector<Vertex> VertexList; int main() { // Create a list for testing VertexList list; Vertex v1 = {1.0f, 2.0f, 3.0f}; list.push_back(v1); Vertex v2 = {2.0f, 100.0f, 3.0f}; list.push_back(v2); Vertex v3 = {3.0f, 200.0f, 3.0f}; list.push_back(v3); Vertex v4 = {4.0f, 300.0f, 3.0f}; list.push_back(v4); // Write out a list to a disk file ofstream os ("data.dat", ios::binary); int size1 = list.size(); os.write((const char*)&size1, 4); os.write((const char*)&list[0], size1 * sizeof(Vertex)); os.close(); // Read it back in VertexList list2; ifstream is("data.dat", ios::binary); int size2; is.read((char*)&size2, 4); list2.resize(size2); // Is it safe to read a whole array of structures directly into the vector? is.read((char*)&list2[0], size2 * sizeof(Vertex)); }

    Read the article

  • StreamWriter stops writing when file is opened from web link

    - by fearofawhackplanet
    Following on from my previous question... The following code creates log files on a web server: private void LogMessage(Message msg) { using (StreamWriter sw = File.AppendText(_logDirectory + DateTime.Now.ToString("yyyyMMddHH") + ".txt")) { sw.WriteLine(msg.ToString()); } } The log files are linked to from an admin page on the web site: foreach (FileInfo file in logDir.GetFiles()) { Response.Write("<a href='http:// .... /Logs/" + file.Name + "'>" + file.Name + "</a>"); } I'm getting the problem that after someone looks at one of the log files from the link, that log file stops being written to.

    Read the article

  • Writing a DTD: How to achieve this children setup

    - by Boldewyn
    The element tasklist may contain at most one title and at most one description, additionally any number (incl. 0) task elements in any order. The naive approach is not applicable, since the order should not matter: <!ELEMENT tasklist (title?, description?, task*) > Alternatively, I could explicitly name all possible options: (title, description?, task*) | (title, task+, description?, task*) | (task+, title, task*, description?, task*) | (description, title?, task*) | (description, task+, title?, task*) | (task+, description, task*, title?, task*) | (task*) but then it's quite easy to write a non-deterministic rule, and furthermore it looks like the direct path to darkest madness. Any ideas, how this could be done more elegantly? And no, an XSD or RelaxNG is no option. I need a plain, old DTD.

    Read the article

  • Problem with writing mobilesubstrate plugins for iOS

    - by overboming
    I am trying to hooking message sending for iOS 3.2, I implement my own hook on a working ExampleHook program I find on the web. But my hook apparently caused segmentation fault everytime it hooks and I don't know why. I want to hook to [NSURL initWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL; and here is my related implementation static id __$GFWInterceptor_NSURL_initWithString2(NSURL<GFWInterceptor> *_NSURL, NSString *URLString, NSURL* baseURL){ NSLog(@"We have intercepted this url: %@",URLString); [_NSURL __HelloNSURL_initWithString:URLString relativeToURL:baseURL]; establish hook Class _$NSURL = objc_getClass("NSURL"); MSHookMessage(_$NSURL, @selector(initWithString:relativeToURL:), (IMP) &__$GFWInterceptor_NSURL_initWithString2, "__HelloNSURL_"); original method declaration - (void)__HelloNSURL_initWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL; and here is my gdb backtrace Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x74696e71 0x335625f8 in objc_msgSend () (gdb) bt 0 0x335625f8 in objc_msgSend () 1 0x32c05b1a in CFStringGetLength () 2 0x32c108a8 in _CFStringIsLegalURLString () 3 0x32b1c32a in -[NSURL initWithString:relativeToURL:] () 4 0x000877c0 in __$GFWInterceptor_NSURL_initWithString2 () 5 0x32b1c220 in +[NSURL URLWithString:relativeToURL:] () 6 0x32b1c1f4 in +[NSURL URLWithString:] () 7 0x3061c614 in createUniqueWebDataURL () 8 0x3061c212 in +[WebFrame(WebInternal) _createMainFrameWithSimpleHTMLDocumentWithPage:frameView:withStyle:editable:] () and apparently it hooks, but there is some memory issue there and I can't find anything to blame now

    Read the article

  • writing to a dataframe from a for-loop in R

    - by CCID
    I'm trying to write from a loop to a data frame in R, for example a loop like this for (i in 1:20) { print(c(i+i,i*i,i/1))} and to write each line of 3 values to a data frame with three columns, so that each iteration takes on a new row. I've tried using matrix, with ncol=3 and filled by rows, but only get the last item from the loop. Thanks.

    Read the article

  • Why isn't this file reading/writing program working?

    - by user320950
    This program is supposed to read files and write them. I took the file open checks out because they kept causing errors. The problem is that the files open like they are supposed to and the names are correct but nothing is on any of the text screens. Do you know what is wrong? #include<iostream> #include<fstream> #include<cstdlib> #include<iomanip> using namespace std; int main() { ifstream in_stream; // reads itemlist.txt ofstream out_stream1; // writes in items.txt ifstream in_stream2; // reads pricelist.txt ofstream out_stream3;// writes in plist.txt ifstream in_stream4;// read recipt.txt ofstream out_stream5;// write display.txt float price=' ',curr_total=0.0; int wrong=0; int itemnum=' '; char next; in_stream.open("ITEMLIST.txt", ios::in); // list of avaliable items out_stream1.open("listWititems.txt", ios::out); // list of avaliable items in_stream2.open("PRICELIST.txt", ios::in); out_stream3.open("listWitdollars.txt", ios::out); in_stream4.open("display.txt", ios::in); out_stream5.open("showitems.txt", ios::out); in_stream.close(); // closing files. out_stream1.close(); in_stream2.close(); out_stream3.close(); in_stream4.close(); out_stream5.close(); system("pause"); in_stream.setf(ios::fixed); while(in_stream.eof()) { in_stream >> itemnum; cin.clear(); cin >> next; } out_stream1.setf(ios::fixed); while (out_stream1.eof()) { out_stream1 << itemnum; cin.clear(); cin >> next; } in_stream2.setf(ios::fixed); in_stream2.setf(ios::showpoint); in_stream2.precision(2); while((price== (price*1.00)) && (itemnum == (itemnum*1))) { while (in_stream2 >> itemnum >> price) // gets itemnum and price { while (in_stream2.eof()) // reads file to end of file { in_stream2 >> itemnum; in_stream2 >> price; price++; curr_total= price++; in_stream2 >> curr_total; cin.clear(); // allows more reading cin >> next; } } } out_stream3.setf(ios::fixed); out_stream3.setf(ios::showpoint); out_stream3.precision(2); while((price== (price*1.00)) && (itemnum == (itemnum*1))) { while (out_stream3 << itemnum << price) { while (out_stream3.eof()) // reads file to end of file { out_stream3 << itemnum; out_stream3 << price; price++; curr_total= price++; out_stream3 << curr_total; cin.clear(); // allows more reading cin >> next; } return itemnum, price; } } in_stream4.setf(ios::fixed); in_stream4.setf(ios::showpoint); in_stream4.precision(2); while ( in_stream4.eof()) { in_stream4 >> itemnum >> price >> curr_total; cin.clear(); cin >> next; } out_stream5.setf(ios::fixed); out_stream5.setf(ios::showpoint); out_stream5.precision(2); out_stream5 <<setw(5)<< " itemnum " <<setw(5)<<" price "<<setw(5)<<" curr_total " <<endl; // sends items and prices to receipt.txt out_stream5 << setw(5) << itemnum << setw(5) <<price << setw(5)<< curr_total; // sends items and prices to receipt.txt out_stream5 << " You have a total of " << wrong++ << " errors " << endl; }

    Read the article

  • Writing a post search algorithm.

    - by MdaG
    I'm trying to write a free text search algorithm for finding specific posts on a wall (similar kind of wall as Facebook uses). A user is suppose to be able to write some words in a search field and get hits on posts that contain the words; with the best match on top and then other posts in decreasing order according to match score. I'm using the edit distance (Levenshtein) "e(x, y) = e" to calculate the score for each post when compared to the query word "x" and post word "y" according to: score(x, y) = 2^(2 - e)(1 - min(e, |x|) / |x|) Each word in a post contributes to the total score for that specific post. This approach seems to work well when the posts are of roughly the same size, but sometime certain large posts manages to rack up score solely on having a lot of words in them while in practice not being relevant to the query. Am I approaching this problem in the wrong way or is there some way to normalize the score that I haven't thought of?

    Read the article

  • Writing to a xml file in java

    - by user243680
    import java.io.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; import org.w3c.dom.*; public class CreatXMLFile { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); // System.out.print("Enter number to add elements in your XML file: "); // String str = bf.readLine(); int no=2; // System.out.print("Enter root: "); String root = "SMS"; DocumentBuilderFactory documentBuilderFactory =DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder =documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.newDocument(); Element rootElement = document.createElement(root); document.appendChild(rootElement); // for (int i = 1; i <= no; i++) // System.out.print("Enter the element: "); // String element = bf.readLine(); String element ="Number"; System.out.print("Enter the Number: "); String data = bf.readLine(); Element em = document.createElement(element); em.appendChild(document.createTextNode(data)); rootElement.appendChild(em); String element1 ="message"; System.out.print("Enter the SMS: "); String data1 = bf.readLine(); Element em1 = document.createElement(element1); em1.appendChild(document.createTextNode(data1)); rootElement.appendChild(em1); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(System.out); transformer.transform(source, result); } } i am working on the above code and it gives the following output run: Enter the Number: 768678 Enter the SMS: ytu <?xml version="1.0" encoding="UTF-8" standalone="no"?><SMS><Number>768678</Number><message>ytu</message></SMS>BUILD SUCCESSFUL (total time: 8 seconds) Now i want to write the output generated(<?xml version="1.0" encoding="UTF-8" standalone="no"?><SMS><Number>768678</Number><message>ytu</message></SMS>) to a XML file on the hard disk.How do i do it?

    Read the article

  • Problem: writing parameter values to data driven MSTEST output

    - by Shubh
    Hi, I am trying to extract some information about the parameter variants used in an MSTEST data driven test case from trx file. Currently, For data driven tests, I get the output of same testcase with different inputs as a sequence of tags , but there is no info about the value of the variants. Example: Suppose we have a [data driven]TestMethod1() and the data rows contain variations a and b. There are two variations a=1,b=2 for which the test passes and a=3,b=4 for which the test fails. If we can output the info that it was a=1,b=2 which passed and a=3 b=4 which failed in the trx file; the output will be meaningful. Better information about test case runs from the output file alone(without any dependencies). Investigating the test failure without rerunning the whole set If the data rows change in data source(now a=1,b=2 pass and a=5,b=6 fail) , easy to decipher that the errors are different; although the fail sequence is still the same(row 0 pass row 1 fail but now row1 is different) Has any of you gone through a similar problem? What did you follow? I tried to put the parameter value information in the Description attribute of TestMethod, it didnt work. Any other methods you think can work too? thanks, Shubhankar

    Read the article

  • Word 2010 for writing invoices, starting with XML

    - by TomTom
    Hello, we are doing quite some invoice generation, and so far it is based on some pretty awful word automation that is now in for a review with Word 2010. I would love to move to a XML based format for storing / presenting invoices, only going to a word document in the last stage. This means I can use easily othermeans to present an invoice internally from the XML. We use Word as "last stage" because Word is a lot better than anything else ever discovered for formatting - our invoices have quite some text sometimes, in the invoice item table, and word is smartest with handling page breaks in the "correct" way. Now, here my question: is there any proper way by now to do this with XML easily? I remember Word having (had) in 2007 some XML field mapping mechanism, but it did not handle tables in the XML. Was anything changed? What would be the proposed approach for generating an .docx document (starting with a .dotx templace) for an invoice, if the relevant data is available in XML form?

    Read the article

  • Writing booleans to file

    - by Sara
    Hello, I have a piece of code that gives a runtime error. Can anyone help find out why? vector<int> intData; vector<bool> boolData; for(int i=0;i<19000;i++) boolData.push_back(false); string ofile = "tree.dat"; ofstream fout(ofile.c_str(),ios::out | ios::binary); if (!boolData.empty()) fout.write((char *)&boolData[0], sizeof(bool)*boolData.size()); fout.close(); It gives the error when it tries to write the file (fout.write).

    Read the article

  • Writing to an already existing file using FileWriter Java

    - by delo
    Is there anyway I can write to an already existing file using Filewriter For example when the user clicks a submit button: FileWriter writer = new FileWriter("myfile.csv"); writer.append("LastName"); writer.append(','); writer.append("FirstName"); writer.append('/n'); writer.append(LastNameTextField.getText()); writer.append(','); writer.append(FirstNameTextField.getText()); I want to be able to write new data into the already existing myfile.csv without having to recreate a brand new one every time

    Read the article

  • Writing an audio player in C#

    - by Malki
    Hi, I have a pretty cool idea for a very special media player. I like to think about this project as a mini-startup, since I don't yet know if my idea is practical. Anyways, before implementing my idea, I first need to be able to implement a simple audio player. My preferred language for this project is C#, simply because it's so easy to use, but any other object oriented language would be fine too I guess. I started out with no knowledge whatsoever about audio. My main goals right now are: Being able to play audio files - as many formats as possible (sort of a VLC type player, but only audio for now). Being able to analyze audio files - as in, reading frequency, amplitude, volume, and other information about the audio. I think maybe a good idea here is to be able to analyze one file format (PCM?), and then temporarily converting any file I want to analyze to that format. This is in order to later implement a mechanism that compares songs and identifies similar songs to recommend to the user (this feature isn't part of my idea, but I figured since it exists in many players nowadays, I need to have it too if I want be able to compete with them). BTW - I currently don't have any knowledge about audio/wavelengths/frequencies and such, so I'd appreciate it if someone could point me in the right direction about this analyzation feature. Maybe in the future I'd expand to playing video files as well, but for now I'm concentrating on audio. After searching the Internet for a while, I've come across LAME. Problem is, it's not C#, and I'm not sure how to use it. I know there is something called "Interoperability", that is supposed to let me work with native DLL files through C#. Any information about that would be helpful as well. Any help would be much appreciated. Thanks, Malki :)

    Read the article

  • StackOverFlow Exception while Writing the Object Graph in to XAML

    - by Jose
    I am trying to Write an object stream into a XAML file but i end up in StackoverFlowException . In the CallStack i could see "The maximum number of stack frames supported by Visual Studio has been exceeded" This is the piece of code i'm trying to execute. StreamWriter xamlStream =new StreamWriter(File.OpenWrite("a.xaml")); string myXaml = System.Windows.Markup.XamlWriter.Save(objectInstance); xamlStream.Write(myXaml); Thanks ...!

    Read the article

  • Looking for best practise for writing a serial device communication app in C#

    - by cdotlister
    I am pretty new to serial comms, but would like advise on how to best achieve a robust application which speak to and listens to a serial device. I have managed to make use of System.IO.serialport, and successfully connected to, sent data to and recieved from my device. The way things work is this. My application connects to the Com Port and opens the port.... I then connect my device to the com port, and it detects a connectio to the PC, so sends a bit of text. it's really just copyright info, as well as the version of the firmware. I don't do anything with that, except display it in my 'activity' window. The device then waits. I can then query information, but sending a command such as 'QUERY PARAMETER1'. It then replies with something like: 'QUERY PARAMETER1\r\n\r\n76767\r\n\r\n' I then process that. I can then update it by sending 'SET PARAMETER1 12345', and it will reply with 'QUERY PARAMETER1\r\n\r\n12345\r\n\r\n'. All pretty basic. So, what I have done is created a Communication Class. this call is called in it's own thread, and sends data back to the main form... and also allows me to send messages to it. Sending data is easy. Recieving is a bit more tricky. I have employed the use of the datarecieved event, and when ever data comes in, I echo that to my screen. My problem is this: When I send a command, I feel I am being very dodgy in my handling. What I am doing is, lets say I am sending 'QUERY PARAMETER1'. I send the command to the device, I then put 'PARAMETER1' into a global variable, and I do a Thread.Sleep(100). On the data recieved, I then have a bit of logic that checks the incoming data, and sees if the string CONTAINS the value in the gloabl variable. As the reply may be 'QUERY PARAMETER1\r\n\r\n76767\r\n\r\n', it sees that it contains my parameter, parses the string, and returns the value I am looking for, but placing it into another global variable. My sending method was sleeping for 100ms. It then wakes, and checks the returned global variable. If it has data... then I'm happy, and I process the data. Problem is... if the sleep is too short.. it will fail. And I feel it's flakey.. putting stuff into variables.. then waiting... The other option is to use ReadLine instead, but that's very blocking. So I remove the datarecieved method, and instead... just send the data... then call ReadLine(). That may give me better results. There's no time, except when we connect initially, that data comes from the device, without me requesting it. So, maybe readline will be simpler and safer? Is this known as 'Blocking' reads? Also, can I set a timeout? Hopefully someone can guide me.

    Read the article

  • Writing in two sessions from the same file (PHP)

    - by bellesebastien
    Hi, I want to make it possible for the administrator to log in as a fontend user from the backend. Right now I'm using two sessions (sessions with different names), one for the admin and one for the frontend. Is it possible to write in the first session, close it and then open a new session? This is a simplified version of what I attempted but failed: session_name('admin_session'); session_start(); // use first session without generatring any output session_close(); session_name('frontend_session'); session_start(); // use the second session Thanks.

    Read the article

  • Problem with writing a file to excel with spreadsheet

    - by winter sun
    I am trying to write excel file by using ruby 1.9 spreadsheet version 0.6.4.1 on windows. Everything is going ok, until I get to the book.write statement when I write book.write "c:/spreadsheet/excel-file.xls I keep getting the following error No such file or directory - c:/spreadsheet/excel-file.xls Can anyone tell me what I should change in this path name?

    Read the article

  • What mutex/locking/waiting mechanism to use when writing a Chat application with Tornado Web Framewo

    - by user272973
    We're implementing a Chat server using Tornado. The premise is simple, a user makes open an HTTP ajax connection to the Tornado server, and the Tornado server answers only when a new message appears in the chat-room. Whenever the connection closes, regardless if a new message came in or an error/timeout occurred, the client reopens the connection. Looking at Tornado, the question arises of what library can we use to allow us to have these calls wait on some central object that would signal them - A_NEW_MESSAGE_HAS_ARRIVED_ITS_TIME_TO_SEND_BACK_SOME_DATA. To describe this in Win32 terms, each async call would be represented as a thread that would be hanging on a WaitForSingleObject(...) on some central Mutex/Event/etc. We will be operating in a standard Python environment (Tornado), is there something built-in we can use, do we need an external library/server, is there something Tornado recommends? Thanks

    Read the article

  • writing XML with Xerces 3.0.1 and C++ on windows

    - by Jon
    Hi, i have the following function i wrote to create an XML file using Xerces 3.0.1, if i call this function with a filePath of "foo.xml" or "../foo.xml" it works great, but if i pass in "c:/foo.xml" then i get an exception on this line XMLFormatTarget *formatTarget = new LocalFileFormatTarget(targetPath); can someone explain why my code works for relative paths, but not absolute paths please? many thanks. const int ABSOLUTE_PATH_FILENAME_PREFIX_SIZE = 9; void OutputXML(xercesc::DOMDocument* pmyDOMDocument, std::string filePath) { //Return the first registered implementation that has the desired features. In this case, we are after a DOM implementation that has the LS feature... or Load/Save. DOMImplementation *implementation = DOMImplementationRegistry::getDOMImplementation(L"LS"); // Create a DOMLSSerializer which is used to serialize a DOM tree into an XML document. DOMLSSerializer *serializer = ((DOMImplementationLS*)implementation)->createLSSerializer(); // Make the output more human readable by inserting line feeds. if (serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true)) serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true); // The end-of-line sequence of characters to be used in the XML being written out. serializer->setNewLine(XMLString::transcode("\r\n")); // Convert the path into Xerces compatible XMLCh*. XMLCh *tempFilePath = XMLString::transcode(filePath.c_str()); // Calculate the length of the string. const int pathLen = XMLString::stringLen(tempFilePath); // Allocate memory for a Xerces string sufficent to hold the path. XMLCh *targetPath = (XMLCh*)XMLPlatformUtils::fgMemoryManager->allocate((pathLen + ABSOLUTE_PATH_FILENAME_PREFIX_SIZE) * sizeof(XMLCh)); // Fixes a platform dependent absolute path filename to standard URI form. XMLString::fixURI(tempFilePath, targetPath); // Specify the target for the XML output. XMLFormatTarget *formatTarget = new LocalFileFormatTarget(targetPath); //XMLFormatTarget *myFormTarget = new StdOutFormatTarget(); // Create a new empty output destination object. DOMLSOutput *output = ((DOMImplementationLS*)implementation)->createLSOutput(); // Set the stream to our target. output->setByteStream(formatTarget); // Write the serialized output to the destination. serializer->write(pmyDOMDocument, output); // Cleanup. serializer->release(); XMLString::release(&tempFilePath); delete formatTarget; output->release(); }

    Read the article

< Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >