Search Results

Search found 35302 results on 1413 pages for 'string literals'.

Page 88/1413 | < Previous Page | 84 85 86 87 88 89 90 91 92 93 94 95  | Next Page >

  • How to create a string array in matlab?

    - by aduric
    I would like to pass a vector of strings from C++ to matlab. I have tried using the functions available such as mxCreateCharMatrixFromStrings but it doesn't give me the correct behavior. So, I have something like this: void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { vector<string> stringVector; stringVector.push_back("string 1"); stringVector.push_back("string 2"); //etc... The problem is how do I get this vector to the matlab environment? plhs[0] = ??? My goal is to be able to run: >> [strings] = MyFunc(...) >> strings(1) = 'string 1'

    Read the article

  • Parse a string containing percent sign into decimal

    - by Sebastian Seifert
    I have a simple string containing VAT-percantage value that needs to be stored in a decimal. The string looks like this: "19.00%". When I use the decimal.Parse() methode I always get an FormatException. Code looks like this NumberFormatInfo nfi = new NumberFormatInfo() { PercentDecimalSeparator = ".", PercentSymbol = "%" }; decimal.Parse("19.00%",NumberStyles.Any, nfi); I know, that it would be possible (in the excample above) to simply remove the %-char from the string and then parse. But isn't there a solution to use built in parsing, which can be used without testing the string for the type of number the user typed in.

    Read the article

  • Why does RIGHT(@foostr, 0) return NULL when @foostr is varchar(max)?

    - by bob-montgomery
    In SQL Server 2005 If I want to find the right-most one character of a varchar(max) variable, no problem: declare @foostr varchar(max) set @foostr = 'abcd' select right (@foostr, 1) ---- d If I want to find the right-most zero characters of a string literal, no problem: select right ('abcd', 0) ------------------ It returns an empty string. If I want to find the right-most zero characters of a varchar(10), no problem: declare @foostr varchar(10) set @foostr = 'abcd' select right (@foostr, 0) ---- It returns an empty string. If I want to find the right-most zero characters of a varchar(max), well: declare @foostr varchar(max) set @foostr = 'abcd' select right (@foostr, 0) ---- NULL It returns NULL. Why?

    Read the article

  • Problems with string parameter insertion into prepared statement

    - by c0d3x
    Hi, I have a database running on an MS SQL Server. My application communicates via JDBC and ODBC with it. Now I try to use prepared statements. When I insert a numeric (Long) parameter everything works fine. When I insert a string parameter it does not work. There is no error message, but an empty result set. WHERE column LIKE ('%' + ? + '%') --inserted "test" -> empty result set WHERE column LIKE ? --inserted "%test%" -> empty result set WHERE column = ? --inserted "test" -> works But I need the LIKE functionality. When I insert the same string directly into the query string (not as a prepared statement parameter) it runs fine. WHERE column LIKE '%test%' It looks a little bit like double quoting for me, but I never used quotes inside a string. I use preparedStatement.setString(int index, String x) for insertion. What is causing this problem? How can I fix it? Thanks in advance.

    Read the article

  • Get value of element in Multi-Dimensional Array

    - by George
    Here is my foreach loop to get at the values from a multi-dimensional array $_coloredvariables = get_post_meta( $post->ID, '_coloredvariables', true ); foreach ($_coloredvariables as $key => $value) { var_dump($value); } Which outputs this: array 'label' => string 'Color' (length=5) 'size' => string 'small' (length=5) 'displaytype' => string 'square' (length=6) 'values' => array 'dark-night-angel' => array 'type' => string 'Image' (length=5) 'color' => string '#2c4065' (length=7) 'image' => string '' (length=0) 'forest-green' => array 'type' => string 'Color' (length=5) 'color' => string '#285d5f' (length=7) 'image' => string '' (length=0) 'voilet' => array 'type' => string 'Color' (length=5) 'color' => string '#6539c9' (length=7) 'image' => string '' (length=0) 'canary-yellow' => array 'type' => string 'Color' (length=5) 'color' => string 'grey' (length=4) 'image' => string '' (length=0) And then to only get the values array I can do this: foreach ($_coloredvariables as $key => $value) { var_dump($value['values']); } which outputs this: array 'dark-night-angel' => array 'type' => string 'Image' (length=5) 'color' => string '#2c4065' (length=7) 'image' => string '' (length=0) 'forest-green' => array 'type' => string 'Color' (length=5) 'color' => string '#285d5f' (length=7) 'image' => string '' (length=0) 'voilet' => array 'type' => string 'Color' (length=5) 'color' => string '#6539c9' (length=7) 'image' => string '' (length=0) 'canary-yellow' => array 'type' => string 'Color' (length=5) 'color' => string 'grey' (length=4) 'image' => string '' (length=0) What I can't figure out is how to get these elements in the array structure "dark-night-angel", "forest-green", "voilet", "canary-yellow" Without using specific names: var_dump($value['values']['dark-night-angel']) Something that is more dynamic, of course this doesn't work: var_dump($value['values'][0][0]); thanks

    Read the article

  • Writing a string which contains " "

    - by dotnetdev
    I have a string from an xml document: <title type="html"> Is there a way for me to write this string like "<title type="html">"? I've had similar problems writing javascript as a string but I did see some solutions in the past (which I can't remember)? Thanks

    Read the article

  • using string to read file - XCode

    - by Fernando
    The following does not work and gives me a SIGABRT when I run in the debugger: std::ifstream inFile; inFile.open("/Users/fernandonewyork/inputText.txt"); cout << inFile << endl; vector<string> inText; if (inFile) { string s4; while (inFile>>s4) { inText.push_back(s4); } } inFile.close(); The following does: std::ifstream inFile; inFile.open("/Users/fernandonewyork/inputText.txt"); cout << inFile << endl; vector<string> inText; if (inFile) { string s4("This is no lnger an empty string"); while (inFile>>s4) { inText.push_back(s4); } } inFile.close(); I was under the impression I was able to simply use s4 without having to worry about any space considerations, or is something else happening here? This is the full error I get from the top code: malloc: * error for object 0x100010a20: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug Program received signal: “SIGABRT”.

    Read the article

  • saving a records containing a member of type string to a file (Delphi, Windows)

    - by wonderer
    I have a record that looks similar to: type TNote = record Title : string; Note : string; Index : integer; end; Simple. The reason I chose to set the variables as string (as opposed to an array of chars) is that I have no idea how long those strings are going to be. They can be 1 char long, 200 or 2000. Of course when I try to save the record to a type file (file of...) the compiler complains that I have to give a size to string. Is there a way to overcome this? or a way to save those records to an untyped file and still maintain a sort of searchable way? Please do not point me to possible solutions, if you know the solution please post code. Thank you

    Read the article

  • Query String to Object with strongly typed properties

    - by Kamar
    Let’s say we track 20 query string parameters in our site. Each request which comes will have only a subset of those 20 parameters. But we definitely look for all/most of the parameters which comes in each request. We do not want to loop through the collection each time we are looking for a particular parameter initially or somewhere down the pipeline in the code. So we loop once through the query string collection, convert string values to their respective types (enums, int, string etc.), populate to QueryString object which is added to the context. After that wherever its needed we will have a strongly typed properties in the QueryString object which is easy to use and we maintain a standard. public class QueryString { public int Key1{ get; private set; } public SomeType Key2{ get; private set; } private QueryString() { } public static QueryString GetQueryString() { QueryString l_QS = new QueryString(); foreach (string l_Key in HttpContext.Current.Request.QueryString.AllKeys) { switch (l_Key) { case "key1": l_QS.Key1= DoSomething(l_Key, HttpContext.Current.Request.QueryString[l_Key]); break; case "key2": l_QS.Key2 = DoAnotherThing(l_Key, HttpContext.Current.Request.QueryString[l_Key]); break; } } return l_QS; } } Any other solution to achieve this?

    Read the article

  • Where should I store user config data? Specificaly the path to the data file?

    - by jamone
    I have an app using a SQLite db, and I need the ability for the user to move the data file and point the app to where it moved to. I used the Entity Framework to create the model, and by default it puts the connection string in the App.Config file. From what I've read if I make changes to the connection string there then they won't take effect until the app is restarted. That seems a bit clunky for my use. I see how I can init my model and pass in a custom string but I'm unsure what the best practice is in where to store basic user prefrences such as this? Ini, Registry, somewhere else? I don't want the user to have to "Open" the file each time, just when it relocates and then the app will try to auto open from then on.

    Read the article

  • Extracting multiple values from a string with RegEx

    - by Toni Frankola
    I have an input string that's generated as in following example: string.Format("Document {0}, was saved by {1} on {2}. The process was completed {3} milliseconds and data was received.", "Document.docx", "John", "1/1/2011", 45); Generate string looks like this then: Document Document.docx, was saved by John on 1/1/2011. The process was completed 45 milliseconds and data was received. Once such a string is received from a different application, what would be the easiest way to parse with regex and extract values Document.docx, John, 1/1/2011, 45 from it. I am looking for the easiest way to do this as we will have to parse a number of different input strings.

    Read the article

  • Maintaining the query string in ASP.Net MVC

    - by Mantorok
    Hi all Just beginning my journey in ASP.Net MVC and I have a query about something before I dig myself in too deep. I have a table, which is paged, and I have 2 controls above the table: Dropdown that defines order of the results and apply button next to it Textbox that defines a filter and apply button next to it What I need to achieve is that if the user changes the order or adds a filter I fire of an AJAX call to my action like such: /Membership/Users?sort=value&filter=value&page=pagenumber. So my controller action is: // GET Membership/Users?sort=&filter=&page= public ActionResult Users(string sort, string filter, string page) So I have 3 questions: Is this the correct approach? What would be the best way to ensure that the query string is maintained, bearing in mind that the action will nearly always be called by Jquery/Ajax functions? If I wanted to link directly to this action passing the arguments would I need to hard-code the querystring? Thanks

    Read the article

  • python regex for repeating string

    - by Lars Nordin
    I am wanting to verify and then parse this string (in quotes): string = "start: c12354, c3456, 34526;" //Note that some codes begin with 'c' I would like to verify that the string starts with 'start:' and ends with ';' Afterward, I would like to have a regex parse out the strings. I tried the following python re code: regx = r"V1 OIDs: (c?[0-9]+,?)+;" reg = re.compile(regx) matched = reg.search(string) print ' matched.groups()', matched.groups() I have tried different variations but I can either get the first or the last code but not a list of all three. Or should I abandon using a regex?

    Read the article

  • oracle search word in string

    - by Atul
    I want to search a word in string in ORACLE in which string is comma separated. Eg. String is ('MF1,MF2,MF3') and now I want to search whether 'MF' exists in that or not. If I am using instr('MF1,MF2,MF3','MF') it will give wrong result since I want to search Full MF in MF1 or MF2 or MF3.

    Read the article

  • Using Apache Velocity with StringBuilders/CharSequences

    - by mindas
    We are using Apache Velocity for dynamic templates. At the moment Velocity has following methods for evaluation/replacing: public static boolean evaluate(Context context, Writer writer, String logTag, Reader reader) public static boolean evaluate(Context context, Writer out, String logTag, String instring) We use these methods by providing StringWriter to write evaluation results. Our incoming data is coming in StringBuilder format so we use StringBuilder.toString and feed it as instring. The problem is that our templates are fairly large (can be megabytes, tens of Ms on rare cases), replacements occur very frequently and each replacement operation triples the amount of required memory (incoming data + StringBuilder.toString() which creates a new copy + outgoing data). I was wondering if there is a way to improve this. E.g. if I could find a way to provide a Reader and Writer on top of same StringBuilder instance that only uses extra memory for in/out differences, would that be a good approach? Has anybody done anything similar and could share any source for such a class? Or maybe there any better solutions to given problem?

    Read the article

  • Safely turning a JSON string into an object

    - by Matt Sheppard
    Given a string of JSON data, how can you safely turn that string into a JavaScript object? Obviously you can do this unsafely with something like... var obj = eval("(" + json + ')'); ...but that leaves us vulnerable to the json string containing other code, which it seems very dangerous to simply eval.

    Read the article

  • Paste a multi-line Java String in Eclipse

    - by Thilo
    Unfortunately, Java has no syntax for multi-line string literals. No problem if the IDE makes it easy to work with constructs like String x = "CREATE TABLE TEST ( \n" + "A INTEGER NOT NULL PRIMARY KEY, \n" ... What is the fastest way to paste a multi-line String from the clipboard into Java source using Eclipse (in a way that it automagically creates code like the above).

    Read the article

  • YouTube - Encrypted cookie string

    - by Robertof
    Hello! I'm new to Stack Overflow. I'm building a YouTube Downloader in PHP. But YouTube have some IP-checks. Because the PHP file is on a remote server, the ip of the server != the ip of the user and the video-download fails. So, maybe I've found a solution. YouTube sends a cookie with an encrypted string, which is the user IP. I need to know the encrypted-string algorithm and know how to crypt a string with this. Here there is the string: nQ0CrJmASJk . It could be base64, but when I try to decode it with base64_decode, it gives me strange characters. You could check the cookie by requesting the main page of youtube, and check the headers "Set-Cookie". You will found a cookie with the name "VISITOR_INFO1_LIVE". Here there is the encrypyed string. Anyone knows what is the algorithm? Thanks. PS: sorry for my bad english. Cheers, Roberto.

    Read the article

  • C# String Resource Values as Enum String Part values?

    - by JL
    Using VS2010 and .net V4.0 I would like to achieve the following: I already have 2 resource files in my project for 2 languages - English and Czech. I must say Resource Management in .net is excellent, I am suprised even to get code completion when implementing a String for example: string desc = Strings.ResourceManagerDesc This gets the string associated with the current culture of the thread. Now I am trying to create an Enum that can have the String portion of the Enum interpreted from the Strings resources. In the following way (This code DOES NOT WORK): public enum DownloadStatus { 1 = Strings.DownloadState_Complete, 2 = Strings.DownloadState_Failed, 3 = Strings.DownloadState_InProgress } This is a made up example, but you can see the point here. Since the above code won't work, is there a best practice way to achieve what I want?

    Read the article

  • C# - implementing GetEnumerator() for a collection inherited from List<string>

    - by Vojtech
    Hi, I am trying to implement FilePathCollection. Its items would be simple file names (without a path - such as "image.jpg"). Once the collection is used via foreach cycle, it should return the full path created by concatenating with "baseDirectory". How can I do that? public class FilePathCollection : List<string> { string baseDirectory; public FileCollection(string baseDirectory) { this.baseDirectory = baseDirectory; } new public System.Collections.IEnumerator GetEnumerator() { foreach (string value in this._list) //this does not work because _list is private yield return baseDirectory + value; } } Thanks in advance! :-)

    Read the article

  • What's wrong with the following code ?

    - by dada
    #include <iostream> #include <string> using namespace std; int main(void) { string a; cin>>a; a.erase(a.end()-1); a.erase(a.begin()+1); string ge = "oae"; a.insert(a.begin()+1, ge); cout<<a<<endl; return 0; } It doesn't compile and i don't know why. Can you tell me what's wrong

    Read the article

  • ArgumentException or ArgumentNullException for string parameters?

    - by Anna Lear
    Far as best practices are concerned, which is better: public void SomeMethod(string str) { if(string.IsNullOrEmpty(str)) { throw new ArgumentException("str cannot be null or empty."); } // do other stuff } or public void SomeMethod(string str) { if(str == null) { throw new ArgumentNullException("str"); } if(str == string.Empty) { throw new ArgumentException("str cannot be empty."); } // do other stuff } The second version seems more precise, but also more cumbersome than the first. I usually go with #1, but figured I'd check if there's an argument to be made for #2.

    Read the article

  • ChoiceFormat.setChoices confusion about format parameter type and documentation

    - by polygenelubricants
    From the java.text.ChoiceFormat API: setChoices(double[] limits, String[] formats): Set the choices to be used in formatting. Parameters: limits - contains [...] formats - are the formats you want to use for each limit. They can be either Format objects or Strings. When formatting with object Y, if the object is a NumberFormat, then ((NumberFormat) Y).format(X) is called. Otherwise Y.toString() is called. I'm having difficulties understanding the documentation for the formats parameter: how can you possibly pass a Format/NumberFormat object to setChoices if it's declared String[] formats? Note that interestingly, the getters counterpart of setChoices are declared as follows: double[] getLimits() Object[] getFormats() -- not String[]!!! Is this a bug in the API? Should the setter have been declared setChoices(double[], Object[]) instead, or am I not understanding how to use setChoices correctly?

    Read the article

< Previous Page | 84 85 86 87 88 89 90 91 92 93 94 95  | Next Page >