Code Comments
Programming Forum and web based access to our favorite programming groups.Hi at all, please can you translate the javascript Parseint() function to a clipper language In particular How can I translate to Clipper 5.3: wDay = parseInt(wDay, 10) if (isNaN(wDay)) wDay = 0 Steel
Post Follow-up to this message"Steel" <SteelNOSPAM@hotmail.com> wrote: > please can you translate the javascript Parseint() function to a clipper > language Not in the general case; that is, not in any bases apart from decimal. > wDay = parseInt(wDay, 10) > if (isNaN(wDay)) > wDay = 0 This snippet, though, parses only decimal numbers anyway, and the Clipper val() returns 0 as its error value in the first place, so you can simply do day=val(day) Do note that this does parse "123aaa" as 123; and does parse "123.45" as 123.45. If you only want integers, you can always ask for int(val(day)). Unfortunately, if you want to make sure there are no non-digits in the string you'll have to make sure of this yourself; if you get the string from user input, a @get with a picture consisting of 9s or #s will not let the user enter non-numeric data in the first place. Richard
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.