Search Results

Search found 9058 results on 363 pages for 'length'.

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

  • C++: type Length from float

    - by anon
    This is kinda like my earlier question: http://stackoverflow.com/questions/2451175/c-vector3-type-wall Except, now, I want to do this to a builtin rather then a user created type. So I want a type "Length" that behaves just like float -- except I'm going to make it's constructor explicit, so I have to explicitly construct Length objects (rather than have random conversions flying around). Basically, I'm going into the type-a-lot camp.

    Read the article

  • Python List length as a string

    - by mvid
    Is there a preferred (not ugly) way of outputting a list length as a string? Currently I am nesting function calls like so: print "Length: %s" % str(len(self.listOfThings)) This seems like a hack solution, is there a more graceful way of achieving the same result?

    Read the article

  • length between 2 values

    - by alex
    In R, what is the most efficient way to count the length between 2 values. for example, i have vector x , which are all randomly choose from 1 to 100, how can i find out the length between the first"2" and first"40", x=(1,2,3,4,5,6,7,40,1,2,3,21,4,1,23,4,43,23,4,12,3,43,5,36,3,45,12,31,3,4,23,41,23,5,53,45,3,7,6,36) for this vector, the answer should be 5 and 6

    Read the article

  • Write string to fixed-length byte array in C#

    - by toasteroven
    somehow couldn't find this with a google search, but I feel like it has to be simple...I need to convert a string to a fixed-length byte array, e.g. write "asdf" to a byte[20] array. the data is being sent over the network to a c++ app that expects a fixed-length field, and it works fine if I use a BinaryWriter and write the characters one by one, and pad it by writing '\0' an appropriate number of times. is there a more appropriate way to do this?

    Read the article

  • Getting length of ParellQuery collection

    - by dotnetdev
    Hi, Is there a way to get the length of a collection from this? ParallelQuery<string> Lines = File.ReadAllLines("Topics.txt").AsParallel<string>(); This has no length property. There is a count method but it takes a Func. If I don't pass a Func paremeter, I could get all the properties in the collection, but how could I not pass one in? Thanks

    Read the article

  • MySQL select column length in php

    - by Patrick
    Hello! How do i get the actual max length of a specified column in php? For instance, this table: id - int(11) name - string(20) I want in php to select the maximum number of characters that a field can have, like SELECT length(name) from table1 and it should then return 20 (since its the maximum number of characters for that field).

    Read the article

  • Variable Length Array

    - by corinaf
    Hello, I would like to know how a variable length array is managed (what extra variables or data structures are kept on the stack in order to have variable length arrays). Thanks a lot.

    Read the article

  • Adding zeros when length is less

    - by David
    Is there a smart way to convert numbers to string and automatically add zeroes so the length is the same as the maximum? like this: for (var i=0; i<30; i++) { var c = i.toString(); if (c.length == 1) { c = '0'+=c; } } But smarter

    Read the article

  • getting string.substring(N) not to choke when N > string.length

    - by aape
    I'm writing some code that takes a report from the mainframe and converts it to a spreadsheet. They can't edit the code on the MF to give me a delimited file, so I'm stuck dealing with it as fixed width. It's working okay now, but I need to get it more stable before I release it for testing. My problem is that in any given line of data, say it could have three columns of numbers, each five chars wide at positions 10, 16, and 22. If on this one particular row, there's no data for the last two cols, it won't be padded with spaces; rather, the length of the string will be only 14. So, I can't just blindly have dim s as string = someStream.readline a = s.substring(10, 5) b = s.substring(16, 5) c = s.substring(22, 5) because it'll choke when it substrings past the length of the string. I know I could test the length of the string before processing each row, and I have automated the filling of some of the vsariables using a counter and a loop, and using the counter*theWidthOfTheGivenVariable to jump around, but this project was a dog to start with (come on! turning a report into a spreadsheet?), but there are many different types of rows (it's not just a grid), and the code's getting ugly fast. I'd like this to be clean, clear, and maintainable for the poor sucker that gets this after me. If it matters, here's my code so far (it's really crufty at the moment). You can see some of my/its idiocy in the processSection#data subs So, I'm wondering 1) is there a way baked in to .NET to have string.substring not error when reading past the end of a string without wrapping it in a try...catch? and 2) would it be appropriate in this situation to write a new string class that inherits from string that has a more friendly substring function in it? ETA: Thanks for all the advice and knowledge everyone. I'll go with the extension. Hopefully one of these years, I'll get my chops up enough to pay someone back in kind. :)

    Read the article

  • How do I write a constant-space length function in Haskell?

    - by Bill
    The canonical implementation of length :: [a] -> Int is: length [] = 0 length (x:xs) = 1 + length xs which is very beautiful but suffers from stack overflow as it uses linear space. The tail-recursive version: length xs = length' xs 0 where length' [] n = n length' (x:xs) n = length xs (n + 1) doesn't suffer from this problem, but I don't understand how this can run in constant space in a lazy language. Isn't the runtime accumulating numerous (n + 1) thunks as it moves through the list? Shouldn't this function Haskell to consume O(n) space and lead to stack overflow? (if it matters, I'm using GHC)

    Read the article

  • create fixed length flat file with Java

    - by Leslie
    I have a process that currently runs in a Delphi application that I wrote and I need to convert it to a Java process that will run on our web application. Basically our State Financial (legacy) system requires this file in a specific output. In Delphi it is like this: procedure CreateSHAREJournalFile(AppDate : string; ClassCode : string; BudgetRef : String; AccountNumber : string; FYEStep : integer); var GLFileInfo : TStrings; MPayFormat, HPayFormat, TPayFormat : string;<br> const<br> //this is the fixed length format for each item in the file<br> HeaderFormat = '%-1s%-5s%-10s%-8s%-12s%-10s%-21s%-3s%-71s%-3s%-20s%-1s';<br> DetailFormat = '%-1s%-5s%-9s%-10s%-10s%-10s%-10s%-8s%-6s%-5s%-5s%-5s%-8s%-25s%-10s%-60s%-28s%-66s%-28s';<br> begin<br> try<br>//get the data from the query<br> with dmJMS.qryShare do<br> begin<br> SQL.Clear;<br> SQL.Add('SELECT SUM(TOTHRPAY) As HourPay, SUM(TOTMLPAY) As MilePay, SUM(TOTALPAY) AS TotalPay FROM JMPCHECK INNER JOIN JMPMAIN ON JMPCHECK.JURNUM = JMPMAIN.JURNUM WHERE PANELID LIKE ''' + Copy(AppDate, 3, 6) + '%'' ');<br> if FYEStep > -1 then<br> SQL.Add('AND WARRANTNO = ' + QUotedStr(IntToStr(FYEStep)));<br> Active := True;<br> //assign totals to variables so they can be padded with leading zeros<br> MPayFormat := FieldByName('MilePay').AsString;<br> while length(MPayFormat) < 28 do <br>MPayFormat := '0' + MPayFormat;<br> HPayFormat := FieldByName('HourPay').AsString;<br> while length(HPayFormat) < 28 do <br>HPayFormat := '0' + HPayFormat;<br> TPayFormat := Format('%f' ,[(FieldByName('TotalPay').AsCurrency)]);<br> while length(TPayFormat) < 27 do<br> TPayFormat := '0' + TPayFormat;<br> TPayFormat := '-' + TPayFormat;<br> //create a TStringlist to put each line item into<br> GLFileInfo := TStringList.Create;<br> //add header info using HeaderFormat defined above<br> GLFileInfo.Add(Format(HeaderFormat, ['H', '21801', 'NEXT', FormatDateTime('MMDDYYYY', Today), '', 'ACTUALS', '', 'EXT', '', 'EXT', '', 'N']));<br> //add detail info using DetailFormat defined above<br> GLFileInfo.Add(Format(DetailFormat, ['L', '21801', '1', 'ACTUALS', AccountNumber, '', '1414000000', '111500', '', '01200', ClassCode, '', BudgetRef, '', AccountNumber + '0300', '', MPayFormat, '', MPayFormat]));<br> GLFileInfo.Add(Format(DetailFormat, ['L', '21801', '2', 'ACTUALS', AccountNumber, '', '1414000000', '111500', '', '01200', ClassCode, '', BudgetRef, '', AccountNumber + '0100', '', HPayFormat, '', HPayFormat]));<br> GLFileInfo.Add(Format(DetailFormat, ['L', '21801', '3', 'ACTUALS', '101900', '', '1414000000', '111500', '', '01200', ClassCode, '', BudgetRef, '', '', '', TPayFormat, '', TPayFormat]));<br> //save TStringList to text file<br> GLFileINfo.SaveToFile(ExtractFilePath(Application.ExeName) + 'FileTransfer\GL_' + formatdateTime('mmddyy', Today) + SequenceID + '24400' + '.txt');<br> end;<br> finally<br> GLFileINfo.Free;<br> end; end; is there an equivalent in Java for the Format option? Or the TStringList that saves to a text file? Thanks for any information....haven't done a lot of Java programming! Leslie

    Read the article

  • jQuery input mask length

    - by Tim
    Hey all, I have an input field and I want to limit it to alphanumerical (A-Z, a-z, 0-9) characters only, with a MINIMUM field length of 5, and a maximum length of up to 15 characters total. Does anyone know how I can do this using jQuery? I'm trying to use the jQuery input mask by digitalBush - http://digitalbush.com/projects/masked-input-plugin/ The problem is that UNLESS I enter 15 characters, the field goes blank. If I enter "012345678912345" (15 characters) in the input field then the value is stored and it's fine. But if I enter "12345" as a username, when that input box loses focus its value goes back to being blank. Is there something that I can change in the "definitions" or options somewhere that fixes this? Many thanks for your help :) Tim

    Read the article

  • Angle and Length of Wind Barb Flags

    - by Kristopher Johnson
    I am working on an application that displays surface winds. Wind speed and direction will be displayed using "wind barb" symbols, as described here: Plotted Winds My question: Are there any standards for the angles and lengths of the "flags" in relation to the the wind-barb "pole"? Eyeballing the diagrams I've seen, I think that an angle of 60 degrees and a flag length about a third as long as the pole length would look fine, but if there are any officially defined standards for these symbols, I'd like to follow them. Note: This app will not be used for navigation, so it is not very important that it look exactly like an official chart. I just don't want it to be ugly, or to look obviously wrong to a knowledgeable user.

    Read the article

  • GAE/Django Templates (0.96) filters to get LENGTH of GqlQuery and filter it

    - by Halst
    I pass the query with comments to my template: COMM = CommentModel.gql("ORDER BY created") doRender(self,CP.template,{'CP':CP,'COMM':COMM, 'authorize':authorize()}) And I want to output the number of comments as a result, and I try to do things like that: <a href="...">{{ COMM|length }} comments</a> Thats does not work (yeah, since COMM is GqlQuery, not a list). What can I do with that? Is there a way to convert GqlQuery to list or is there another solution? (first question) Second question is, how to filter this list in template? Is there a construct like this: <a href="...">{{ COMM|where(reference=smth)|length }} comments</a> so that I can get not only the number of all comments, but only comments with certain db.ReferenceProperty() property, for example. Last question: is it weird to do such things using templates?

    Read the article

  • HTTP Headers for Unknown Content-Length

    - by jocull
    I am currently trying to stream content out to the web after a trans-coding process. This usually works fine by writing binary out to my web stream, but some browsers (specifically IE7, IE8) do not like not having the Content-Length defined in the HTTP header. I believe that "valid" headers are supposed to have this set. What is the proper way to stream content to the web when you have an unknown Content-Length? The trans-coding process can take awhile, so I want to start streaming it out as it completes.

    Read the article

  • Android: videocamera, limit length of videos taken

    - by AP257
    I'm working in Android and starting the video camera activity using ACTION_VIDEO_CAPTURE. Is there any way I can limit the length (in time) of the videos the user can take? I think this is possible if you use MediaRecorder, but I don't really fancy doing that since it's so much more complicated than using the simple ACTION_VIDEO_CAPTURE. Current code: Intent videoCaptureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(videoCaptureIntent,1); If it's not possible, does anyone know whether I could set a timer (TimerTask?) in Java and then show a Toast message after a certain length of time warning the user that they need to stop filming? (I'm a Java newbie, so I don't know if this is exactly what I need.)

    Read the article

  • Setting column length of a Long value with JPA annotations

    - by Gearóid
    Hi, I'm performing a little database optimisation at the moment and would like to set the column lengths in my table through JPA. So far I have no problem setting the String (varchar) lengths using JPA as follows: @Column(unique=true, nullable=false, length=99) public String getEmail() { return email; } However, when I want to do the same for a column which is of type Long (bigint), it doesn't work. For example, if I write: @Id @Column(length=7) @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { return id; } The column size is still set as the default of 20. Are we able to set these lengths in JPA or am I barking up the wrong tree? Thanks, Gearoid.

    Read the article

  • How to properly test Hibernate length restriction?

    - by Cesar
    I have a POJO mapped with Hibernate for persistence. In my mapping I specify the following: <class name="ExpertiseArea"> <id name="id" type="string"> <generator class="assigned" /> </id> <version name="version" column="VERSION" unsaved-value="null" /> <property name="name" type="string" unique="true" not-null="true" length="100" /> ... </class> And I want to test that if I set a name longer than 100 characters, the change won't be persisted. I have a DAO where I save the entity with the following code: public T makePersistent(T entity){ transaction = getSession().beginTransaction(); transaction.begin(); try{ getSession().saveOrUpdate(entity); transaction.commit(); }catch(HibernateException e){ logger.debug(e.getMessage()); transaction.rollback(); } return entity; } Actually the code above is from a GenericDAO which all my DAOs inherit from. Then I created the following test: public void testNameLengthMustBe100orLess(){ ExpertiseArea ea = new ExpertiseArea( "1234567890" + "1234567890" + "1234567890" + "1234567890" + "1234567890" + "1234567890" + "1234567890" + "1234567890" + "1234567890" + "1234567890"); assertTrue("Name should be 100 characters long", ea.getName().length() == 100); ead.makePersistent(ea); List<ExpertiseArea> result = ead.findAll(); assertEquals("Size must be 1", result.size(),1); ea.setName(ea.getName()+"1234567890"); ead.makePersistent(ea); ExpertiseArea retrieved = ead.findById(ea.getId(), false); assertTrue("Both objects should be equal", retrieved.equals(ea)); assertTrue("Name should be 100 characters long", (retrieved.getName().length() == 100)); } The object is persisted ok. Then I set a name longer than 100 characters and try to save the changes, which fails: 14:12:14,608 INFO StringType:162 - could not bind value '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' to parameter: 2; data exception: string data, right truncation 14:12:14,611 WARN JDBCExceptionReporter:100 - SQL Error: -3401, SQLState: 22001 14:12:14,611 ERROR JDBCExceptionReporter:101 - data exception: string data, right truncation 14:12:14,614 ERROR AbstractFlushingEventListener:324 - Could not synchronize database state with session org.hibernate.exception.DataException: could not update: [com.exp.model.ExpertiseArea#33BA7E09-3A79-4C9D-888B-4263314076AF] //Stack trace 14:12:14,615 DEBUG GenericDAO:87 - could not update: [com.exp.model.ExpertiseArea#33BA7E09-3A79-4C9D-888B-4263314076AF] 14:12:14,616 DEBUG JDBCTransaction:186 - rollback 14:12:14,616 DEBUG JDBCTransaction:197 - rolled back JDBC Connection That's expected behavior. However when I retrieve the persisted object to check if its name is still 100 characters long, the test fails. The way I see it, the retrieved object should have a name that is 100 characters long, given that the attempted update failed. The last assertion fails because the name is 110 characters long now, as if the ea instance was indeed updated. What am I doing wrong here?

    Read the article

  • C# - split String into smaller Strings by length variable

    - by tyndall
    I'd like to break apart a String by a certain length variable. It needs to bounds check so as not explode when the last section of string is not as long as or longer than the length. Looking for the most succinct (yet understandable) version. Example: string x = "AAABBBCC"; string[] arr = x.SplitByLength(3); // arr[0] -> "AAA"; // arr[1] -> "BBB"; // arr[2] -> "CC"

    Read the article

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