Search Results

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

Page 68/1413 | < Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >

  • C# find a value from an object column using a string from another column

    - by Graham
    I have 2 list in foreach loops.. I currently use a 'switch' statement on the m.columnname and then assign the value of that column to another var map as per below.. If m.columnname = 'DocHeading' then v.docheading is assigned to map.value.. There will always be a match on m.columnname to a column in the var v. is there a way to get the value from the var v using the string from m.columnname? The reason is that the users will want to add and change column names and I dont want to have to change this code all the time.. Hope this makes sense List spreadMapping = new List(); foreach (var m in mappings) { foreach (var v in hvalues) { SpreadMappings map = new SpreadMappings(); switch (m.ColumnName) { case “DocHeading”: map.ColumnX = m.ColumnX; map.ColumnY = m.ColumnY; map.ColumnValue = v.DocHeading; map.ColumnName = m.ColumnName; map.ColumnId = v.Id; map.ColumnSheetName = sheetName; spreadMapping.Add(map); break;

    Read the article

  • Complex string matching with fuzzywuzzy

    - by That1Guy
    I'm attempting to write a process that matches obscure strings to a single 'master string' for further processing. I have a lot of data that looks something like this: Basketball Basket Ball Football BasketBallR BBall BBall - r FootB ...and so on. These need to be mapped to a master record like so: Basketball = Basket Ball, BBall Basketball - R = BasketBallR, BBall - r I also have instances of data resembling this format: Football -r FootBall - r-g/H,Q,HH These situations need to be separated into different categories before being mapped. For example FootBall - r-g/H,Q,HH should be: Football - r Football - g Football - H Football - Q Football - HH At this point, it still needs to be mapped to a master record... I've tried several different combinations of fuzzywuzzy matching methods, Levenshtein Distance measurements, regex, etc. and can't seem to find a reliable method to logically associate different naming styles of a single item with a master name. I'm throwing my hands up in desperation. Are there any existing python resources than can help sort out my problem? Are there other options? Can anybody point out an obvious option that I might have overlooked? Basically, any suggestion, solution, resource or alternative method is greatly appreciated.

    Read the article

  • String on a model

    - by alecnash
    I am trying to put a sting on a Model and I want it to be dynamic. Did some research and came up with drawing the text on the texture and then set it on the model. I use something like this: public static Texture2D SpriteFontTextToTexture(SpriteFont font, string text, Color backgroundColor, Color textColor) { Size = font.MeasureString(text); RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, (int)Size.X, (int)Size.Y); GraphicsDevice.SetRenderTarget(renderTarget); GraphicsDevice.Clear(Color.Transparent); Spritbatch.Begin(); //have to redo the ColorTexture Spritbatch.Draw(ColorTexture.Create(GraphicsDevice, 1024, 1024, backgroundColor), Vector2.Zero, Color.White); Spritbatch.DrawString(font, text, Vector2.Zero, textColor); Spritbatch.End(); GraphicsDevice.SetRenderTarget(null); return renderTarget; } When I was working with primitives and not models everything worked fine because I set the texture exactly where I wanted but with the model (RoundedRect 3d button) it looks like that: Is there a way to have the text centered only on one side?

    Read the article

  • StreamReader.ReadToEnd() returning an empty string

    - by axk
    I have a method private static String DecompressAndDecode(byte[] data) { GZipStream decompressor = new GZipStream(new MemoryStream(data), CompressionMode.Decompress); StreamReader decompressed = new StreamReader(decompressor, Encoding.UTF8); String result = decompressed.ReadToEnd(); return result; } I have some GZipped text as input and the result is supposed to be a String representation of this text. The problem is that the method returns an empty string. What is puzzling me is that when I step trough the method in debug mode and reach the return statement the result variable is an empty string but if I create a watch for the decompressed.ReadToEnd() expression it returns me the text. What I would expect at this point is the result variable to contain the text and the decompressed.ReadToEnd() expression evaluating to an empty string. (Reevaluating the decompressed.ReadToEnd() expression returns an empty string as expected). There must be something obvious I'm missing here.

    Read the article

  • Is there a literal notation for decimal in IronPython?

    - by jeroenh
    suppose I have the following IronPython script: def Calculate(input): return input * 1.21 When called from C# with a decimal, this function returns a double: var python = Python.CreateRuntime(); dynamic engine = python.UseFile("mypythonscript.py") decimal input = 100M; // input is of type Decimal // next line throws RuntimeBinderException: // "cannot implicitly convert double to decimal" decimal result = engine.Calculate(input); I seem to have two options: First, I could cast at the C# side: seems like a no-go as I might loose precision. decimal result = (decimal)engine.Calculate(input); Second option is to use System.Decimal in the python script: works, but pollutes the script, which should be understandable for my users... import clr import System def CalculateVAT(amount): return amount * System.Decimal(1.21) Is there a way to tell the DLR that the number 1.21 should be interpreted as a Decimal, much like I would use the '1.21M' notation in C#?

    Read the article

  • StremReader.ReadToEnd() returning an empty string

    - by axk
    I have a method private static String DecompressAndDecode(byte[] data) { GZipStream decompressor = new GZipStream(new MemoryStream(data), CompressionMode.Decompress); StreamReader decompressed = new StreamReader(decompressor, Encoding.UTF8); String result = decompressed.ReadToEnd(); return result; } I have some GZipped text as input and the result is supposed to be a String representation of this text. The problem is that the method returns an empty string. What is puzzling me is that when I step trough the method in debug mode and reach the return statement the result variable is an empty string but if I create a watch for the decompressed.ReadToEnd() expression it returns me the text. What I would expect at this point is the result variable to contain the text and the decompressed.ReadToEnd() expression evaluating to an empty string. (Reevaluating the decompressed.ReadToEnd() expression returns an empty string as expected). There must be something obvious I'm missing here.

    Read the article

  • Write a program that allows the user to enter a string and then prints the letters of the String sep

    - by WM
    The output is always a String, for example H,E,L,L,O,. How could I limit the commas? I want the commas only between letters, for example H,E,L,L,O. import java.util.Scanner; import java.lang.String; public class forLoop { public static void main(String[] args) { Scanner Scan = new Scanner(System.in); System.out.print("Enter a string: "); String Str1 = Scan.next(); String newString=""; String Str2 =""; for (int i=0; i < Str1.length(); i++) { newString = Str1.charAt(i) + ","; Str2 = Str2 + newString; } System.out.print(Str2); } }

    Read the article

  • what is this called? and how to achieve it?

    - by user287745
    i would like to make a WRITE A NEW POST page similar to asp.net or how to make a page similar to http://stackoverflow.com/questions/ask please note, i do not want reference to already made controls like free rich text editor etc i would like to do the required coding my self any guidance will be appreciated i would also like to know what is the name given to this kind of page? as i search google for how to make a post and it comes up with et and post methods of html initial attempt:- on button click post back event within the update plane, literal1.text=textbox1.text assuming that user will provide formats like bold, but the textbox is not taking any such input.

    Read the article

  • JavaScript function, which reads connections between objects

    - by Nikita Sumeiko
    I have a JavaScript literal: var members = { "mother": { "name" : "Mary", "age" : "48", "connection": { "brother" : "sun" } }, "father": { "name" : "Bill", "age" : "50" }, "brother": { "name" : "Alex", "age" : "28" } } Than I have a function, which should read connections from the literal above. It looks like this: function findRelations(members){ var wires = new Array(); var count = 0; for (n = 0; n < members.length; n++){ alert(members.length); // this alert is undefined if (members[n].connection){ for (i = 0; i < members[n].connection[0].length; i++){ var mw = new Array(); var destination = 0; for (m = 0; m < members.length; m ++){ if (members[m] == members[n].connection[0]){ destination = m; mw = [n, destination]; wires [count] = mw; count++; } } } } } return wires; } However, when I run this function, I get nothing. And the first alert, which is placed inside the function shows 'undefined' at all. findRelations(members); alert("Found " + wires.length + " connections"); I guess that's because of JavaScript literal. Could you suggest how to change a function or perhaps to change litteral to JSON array to get it work?! And at the end to get 'm' and 'n' values as numbers.

    Read the article

  • How can I clip strings in Java2D and add ... in the end?

    - by Jonas
    I'm trying to print Invoices in a Java Swing applications. I do that by extending Printable and implement the method public int print(Graphics g, PageFormat pf, int page). I would like to draw strings in columns, and when the string is to long I want to clip it and let it end with "...". How can I measure the string and clip it at the right position? Some of my code: Font headline = new Font("Times New Roman", Font.BOLD, 14); g2d.setFont(headline); FontMetrics metrics = g2d.getFontMetrics(headline); g2d.drawString(myString, 0, 20); I.e How can I limit myString to be max 120px? I could use metrics.stringWidth(myString), but I don't get the position where I have to clip the string. Expected results could be: A longer string that exc... A shorter string. Another long string, but OK

    Read the article

  • Is it possible to bind arrays of literals in sqlite3-ruby?

    - by willb
    I'd like to execute the following sort of query through sqlite3-ruby: SELECT * FROM foo WHERE bar IN (:items) and bind :items to one or many literals. Is this possible? The obvious technique of passing the list of literals as an array as follows doesn't seem to work: db.execute("SELECT * FROM foo WHERE bar IN (:items)", :items=>[3,1]) (In the above example, only the first value in the array is bound to :items.)

    Read the article

  • TSQL - make a literal float value

    - by David B
    I understand the host of issues in comparing floats, and lament their use in this case - but I'm not the table author and have only a small hurdle to climb... Someone has decided to use floats as you'd expect GUIDs to be used. I need to retrieve all the records with a specific float value. sp_help MyTable -- Column_name Type Computed Length Prec -- RandomGrouping float no 8 53 Here's my naive attempt: --yields no results SELECT RandomGrouping FROM MyTable WHERE RandomGrouping = 0.867153569942739 And here's an approximately working attempt: --yields 2 records SELECT RandomGrouping FROM MyTable WHERE RandomGrouping BETWEEN 0.867153569942739 - 0.00000001 AND 0.867153569942739 + 0.00000001 -- 0.867153569942739 -- 0.867153569942739 In my naive attempt, is that literal a floating point literal? Or is it really a decimal literal that gets converted later? If my literal is not a floating point literal, what is the syntax for making a floating point literal? EDIT: Another possibility has occurred to me... it may be that a more precise number than is displayed is stored in this column. It may be impossible to create a literal that represents this number. I will accept answers that demonstrate that this is the case. EDIT: response to DVK. TSQL is MSSQLServer's dialect of SQL. This script works, and so equality can be performed deterministically between float types: DECLARE @X float SELECT top 1 @X = RandomGrouping FROM MyTable WHERE RandomGrouping BETWEEN 0.839110948199148 - 0.000000000001 AND 0.839110948199148 + 0.000000000001 --yields two records SELECT * FROM MyTable WHERE RandomGrouping = @X I said "approximately" because that method tests for a range. With that method I could get values that are not equal to my intended value. The linked article doesn't apply because I'm not (intentionally) trying to straddle the world boundaries between decimal and float. I'm trying to work with only floats. This isn't about the non-convertibility of decimals to floats.

    Read the article

  • String handle in C#

    - by Chelsea_cole
    I don't understand the use of "get" and "set" command, how to add a list of the accounts using the code below and someone give me some example to fix the error? Thanks! :( public class Account { public string UserName {get rerurn textBox1.Test; // error set UserName = textBox1.Text;} // error public string Password { get; set; } public string RePassword { get; set; } public string Name { get; set; } public string bd { get; set; } public string dt { get; set; } public string dc { get; set; } } public class ListAcc { static void Data() { List<Account> UserList = new List<Account>(); } }

    Read the article

  • Function for averages of tuples in a dictionary

    - by Billy Mann
    I have a string, dictionary in the form: ('the head', {'exploded': (3.5, 1.0), 'the': (5.0, 1.0), "puppy's": (9.0, 1.0), 'head': (6.0, 1.0)}) Each parentheses is a tuple which corresponds to (score, standard deviation). I'm taking the average of just the first integer in each tuple. I've tried this: def score(string, d): for word in d: (score, std) = d[word] d[word]=float(score),float(std) if word in string: word = string.lower() number = len(string) return sum([v[0] for v in d.values()]) / float(len(d)) if len(string) == 0: return 0 When I run: print score('the head', {'exploded': (3.5, 1.0), 'the': (5.0, 1.0), "puppy's": (9.0, 1.0), 'head': (6.0, 1.0)}) I should get 5.5 but instead I'm getting 5.875. Can't figure out what in my function is not allowing me to get the correct answer.

    Read the article

  • binary number in c++

    - by baash05
    In c++ 0x10 is the way to represent a hex value. if I leave off the 0x then it's dec. Is there a way to define a binary? Not that I can't derive 0x0003 is 11, but it would be cool if I could use 0b0011. It would just make the code a little more obvious.

    Read the article

  • Convert Java String to Array

    - by Bruce
    This is a weird problem. Here is my code String reply = listen.executeUrl("http://localhost:8080/JavaBridge/reply.php); executeUrl returns as String object whatever is returned by the reply.php file. Now comes the problem. In reply.php I am returning an PHP array and reply is a String. When I do System.out.println("Reply = "+reply); I get Reply = array(2) { [0]=> string(14) "Dushyant Arora" [1]=> string(19 ) "@dushyantarora13 hi"} But reply is still a String. How do I convert it into a String array or an Array.

    Read the article

  • Passing variable string to create arrays (Android)

    - by dweebsonduty
    Hello all, I am a newb to Android and Java and want to write a funtion that will display a list based on a varable that I pass to the function. The function is below and the code below creates an array out of a string called type, but what I want to do is pass it a variable string and have it build a list based on that string. So if I wanted the type list I would say list_it("type") But if I try something like getResources().getStringArray(R.array.thelist); it doesn't work. Can someone point me in the right direction? public void list_it(String thelist){ String[] types = getResources().getStringArray(R.array.type); ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(this, R.layout.list_item1, types); setListAdapter(mAdapter); ListView lv = getListView(); lv.setTextFilterEnabled(true); }

    Read the article

  • C# sqlite query results to list<string>

    - by jakesankey
    Guys, I'm struggling. I have query against my db that returns a single column of data and I need to set it as List. Here is what I am working with and I am getting an error about converting void to string. public static void GetImportedFileList() { using (SQLiteConnection connect = new SQLiteConnection(@"Data Source=C:\Documents and Settings\js91162\Desktop\CMMData.db3")) { connect.Open(); using (SQLiteCommand fmd = connect.CreateCommand()) { SQLiteCommand sqlComm = new SQLiteCommand(@"SELECT DISTINCT FileName FROM Import"); SQLiteDataReader r = sqlComm.ExecuteReader(); while (r.Read()) { string FileNames = (string)r["FileName"]; List<string> ImportedFiles = new List<string>(); } connect.Close(); } } } THEN LATER IN THE APPLICATION List<string> ImportedFiles = GetImportedFileList() // Method that gets the list of files from the db foreach (string file in files.Where(fl => !ImportedFiles.Contains(fl)))

    Read the article

  • Casting Class into String and Vice Versa in JAVA

    - by topgun_ivard
    I have a program in which I need to store a Class object into memory by casting it into String. Is it possible to convert the String back into the original Class so that I can use that class variables? I am doing this in JAVA. Example: test.java class hello{ public String h1; public String h2; } public class test { public static void main(String[] args) { hello h = new hello(); h.h1 = "hello"; h.h2 = "world"; String s = h.toString(); System.out.println("Print s : "+s); // Now I need to convert String s into type hello so that // I can do this: // (hello)s.h1; // (hello)s.h2; } } NOTE: this is not a homework, this is a personal project and I would be grateful if anyone can help! Thanks! Ivar

    Read the article

  • Initializing a value through a Session variable

    - by William Calleja
    I need to Initialize a value in a Javascript by using a c# literal that makes reference to a Session Variable. I am using the following code <script type="text/javascript" language="javascript" > var myIndex = <%= !((Session["myIndex"]).Equals(null)||(Session["myIndex"]).Equals("")) ? Session["backgroundIndex"] : "1" %>; However the code above is giving me a classic Object reference not set to an instance of an object. error. Why? Shouldn't (Session["myIndex"]).Equals(null) capture this particular error?

    Read the article

  • Fortran - String with unknown characters into substrings

    - by Masoud
    I am trying to put an input string into sub-string arrays. The number of data in the input file are less than 10 but unknown. The number of spaces between each data is also unclear. Example: Asd B Cwqe21 Ddsw Eww I am quite novice to Fortran, so I do not know which format I should use. My problem is that I do not know the number of data (here I assumed that there are 5), so how can I make the code work? I tried the following which did not work: CHARACTER (LEN=100), DIMENSION(10) :: string READ (1,*) (string,I=1,10) It seems that the error I got was because there was no 6th string to read and put into string(6). I tried using the "Index" to find the space, but since I do not know how many spaces are in the string, it did not help me.

    Read the article

  • seprate a string array to several small arrays

    - by blgnklc
    how can I separate an array in smaller arrays? string[] str = new string[145] I want two arrays for this; like string[] str1 = new string[99]; string[] str2 = new string[46]; how can I do this from the source of str? 1- Then I want to put togetger the arrays into List all together but there is only add item? no add items? or any other way to make the string[145] array again..

    Read the article

  • Splitting html string after so many words

    - by jimbo
    Hi all, I have a string that if it is longer than lets say 10 words, I want to split it into two parts. The second part will be included else-where after a 'more' link. The string will hold html tags too though. For an example the string could be: <p>This is just a test string with more words than the <strong>amount allow</strong> before split, blah blah blah</p> So in the case I would want: $string[0] // <p>This is just a test string with more words than</p>; $string[1] // <p>the <strong>amount allow</strong> before split, blah blah blah</p>; Thanks in advance

    Read the article

  • how can I enter character "<" in strings.xml?

    - by yrajabi
    I want to enter string " -< " in strings.xml file, the string has character < and I couldn't add it to xml file without error! I even tried to escaping by \ character: <string name="search_target_arrow"> -\< </string> or enclosing it between "" as below: <string name="search_target_arrow">" -< "</string> but none worked. Maybe I'm very amateur at this and the answer is not hard for you. so please tell me how you add such special chars in strings.xml?

    Read the article

< Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >