Re: Testing for numerics
OIC Jim. I think you've nailed it. A declared global does NOT show up in the globals UNTIL you put something into it! Brilliant! So is there a handler that gets triggered if I declare a global? If so, I can intercept it and auto-initialize it with a handler to null and never have to change a line of Foxpro code that checks for null globals! BRILLIANT!!! I turned the message watcher on but cannot discern if any of the messages are the result of declaring a global variable. Still, this is workable. Bob Sneidar IT Manager Logos Management Calvary Chapel CM On Oct 9, 2006, at 6:46 PM, Jim Ault wrote: You're right, of course - there's no way to just declare a global and then later try and tell the difference between it being newly declared and it having had empty put into it. Ken, I beg to differ, but perhaps I don't know enough about globals in Rev Globals are in the Rev space, owned by Rev, and will persist even if all stacks are closed and removed from memory... however ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Globals, trapping using setProp [was Re: Testing for numerics]
If you want a trigger, Rev sends messages for both setting and getting custom properties. Sohh... a one-liner is all we need in our working scripts.. set the trapGlobalEvent of this stack to gExecuteStatus --I made up trapGlobaEvent¹ and one handler in the stack or back script or library setProp trapGlobalEvent glbName -- do some stuff end trapGlobalEvent Below is a working script, so just create a new Mainstack, paste the following into the stack script, apply, then doubleClick anywhere on the stack to see how it works. start copy script here --- on mouseDoubleUp -- a stack script, card, button, field, group, front --we want to initiate a global and supply a trigger --using a one-liner in any Rev handler -- our global is named 'gExecuteStatus' set the trapGlobalEvent of this stack to gExecuteStatus end mouseDoubleUp setProp trapGlobalEvent glbName -- a stack script, back script, or stackinuse (library) --triggered by the handler mouseDoubleUp in the stk script answer glbName triggered by mouseDoubleUp from the target --optional do (global glbName) --declare do (get glbName is among the items of the globals) --retrieve if it is true then exit trapGlobalEvent --already done do (put null into glbName) --init value to null breakpoint --install temporarily until you know you did not --create a recursion event/trap loop (see below) -- --we don't care about actually setting the custom property -- --we just want to TRAP the event that we triggered -- --then -- -- take the action of declaring and giving it to Rev -- --and [ ta-da ] auto-initialize it to null -- -- -- --and trapGlobalEvent never gets created -- --on the other hand -- --we could count the number of events by set the lockmessages to true to avoid recursion* get the trapGlobalEvent of this stack set the trapGlobalEvent of this stack to (it+1) --does the setting get the trapGlobalEvent of this stack set the lockmessages to false answer the trapGlobalEvent of this stack has been triggered it times--optional --save this stack --if you wish persistence, like path names, etc end trapGlobalEvent --avoid recursion* means that -- our line of code that sets the trapGlobalEvent would be caught --by the same handler ... this one! So by locking messages, none is --sent, but the customProperty IS updated by rev. A nice subtlety, eh? ---end copy script here -- Hope this helps you get the most out of your global system On 10/12/06 1:20 PM, Robert Sneidar [EMAIL PROTECTED] wrote: OIC Jim. I think you've nailed it. A declared global does NOT show up in the globals UNTIL you put something into it! Brilliant! So is there a handler that gets triggered if I declare a global? If so, I can intercept it and auto-initialize it with a handler to null and never have to change a line of Foxpro code that checks for null globals! BRILLIANT!!! I turned the message watcher on but cannot discern if any of the messages are the result of declaring a global variable. Still, this is workable. Bob Sneidar ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
global gVar2 on mouseUp breakpoint --gVar2 appears in Variable Watcher, but not in (the globals) Cool! I didn't know that this happened... this might be quite useful. Thanks for the info! Which is why I suggested testing against prior usage... if gAGlobal is not among the items of the globals then global gAGlobal put 10 into gAGlobal -- or NULL or whatever end if /H ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Hi Ken. With all due respect, your example would only work if I declared the global inside a script (and therefore every script that uses it). And then it would put null into the global regardless of what was in it before. That would be disastrous. You might say I could just check to see if anything was in it, but that leads us back to the original question, which is, how do I discern between a global that just got declared but has yet to have anything put into it, and a global that is simply empty at the moment. The answer of course, is you can't do that. But thanks to all who wanted to help. I am just going to have to code around this by creating init flags throughout the code whenever a global was checked for null, and use those instead. Bob Sneidar IT Manager Logos Management Calvary Chapel CM On Oct 8, 2006, at 10:27 AM, Ken Ray wrote: snip Actually, since the null value is supported, and since you can't initialize a global with a value anyway (can't do global myGlob = 4), you'd have to assign a value anyway, so why not null: global gMyGlob put null into gMyGlob ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On 10/9/06 3:21 PM, Robert Sneidar [EMAIL PROTECTED] wrote: Hi Ken. With all due respect, your example would only work if I declared the global inside a script (and therefore every script that uses it). And then it would put null into the global regardless of what was in it before. That would be disastrous. Actually, I don't think you understand fully what I was getting at. I didn't mean that you declare the global and put NULL into it *in every script*... what I meant was that at the absolute beginning of execution (your first preOpenStack, say), you declare all the globals and put NULL into them: global gMyGlob1, gMyGlob2 on preOpenStack put null into gMyGlob1 put null into gMyGlob2 -- (etc.) end preOpenStack Then later on, you can check the global (all you'd need to do is declare the global in the script that needs to check it - don't assign anything to it), and if it is NULL then it means it hasn't been changed since it was originally declared at the beginning of execution. If it was empty, it would mean that somewhere along the line a script line set it to empty: (script of a button on some stack): global gMyGlob1 on mouseUp if gMyGlob1 = NULL then -- you know it has never had its value set since its original -- declaration else -- you know that *someone* changed the value of this global -- even if it is empty (i.e. ) end if end mouseUp You might say I could just check to see if anything was in it, but that leads us back to the original question, which is, how do I discern between a global that just got declared but has yet to have anything put into it, and a global that is simply empty at the moment. The answer of course, is you can't do that. You're right, of course - there's no way to just declare a global and then later try and tell the difference between it being newly declared and it having had empty put into it. But thanks to all who wanted to help. I am just going to have to code around this by creating init flags throughout the code whenever a global was checked for null, and use those instead. You can do that, or you can declare all the globals as NULL as I've outlined above... Ken Ray Sons of Thunder Software Web site: http://www.sonsothunder.com/ Email: [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On 10/9/06 3:06 PM, Ken Ray [EMAIL PROTECTED] wrote: You're right, of course - there's no way to just declare a global and then later try and tell the difference between it being newly declared and it having had empty put into it. Ken, I beg to differ, but perhaps I don't know enough about globals in Rev Globals are in the Rev space, owned by Rev, and will persist even if all stacks are closed and removed from memory... however global gVar2 on mouseUp breakpoint --gVar2 appears in Variable Watcher, but not in (the globals) answer gVar2 is in the globals --FALSE, since it is unused put 2 into gVar2 answer gVar2 is in the globals --TRUE, until Rev quits --it now appears in Variable Watcher listing = 2 end mouseUp --it now appears in Variable Watcher listing = 2 --along with the environmental globals Thus you would not have to use NULL, just the line if gVar2 is not in the globals then ...it is less that NULL --we are testing the string gVar2, not the value Note that Variable Watcher will show the globals values if no handler is running (except global arrays. they will appear blank, but retain their value, which can be seen the next time you drop into the debugger) Script locals / handler locals are purged by the stack / handler. So... when is a global less than null and not empty? When it is declared but not used. PS. Environmental globals have to be declared to be used, as well. Hope this is correct. Jim Ault Las Vegas ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On 10/9/06 8:46 PM, Jim Ault [EMAIL PROTECTED] wrote: On 10/9/06 3:06 PM, Ken Ray [EMAIL PROTECTED] wrote: You're right, of course - there's no way to just declare a global and then later try and tell the difference between it being newly declared and it having had empty put into it. Ken, I beg to differ, but perhaps I don't know enough about globals in Rev Globals are in the Rev space, owned by Rev, and will persist even if all stacks are closed and removed from memory... however global gVar2 on mouseUp breakpoint --gVar2 appears in Variable Watcher, but not in (the globals) Cool! I didn't know that this happened... this might be quite useful. Thanks for the info! PS. Environmental globals have to be declared to be used, as well. Actually, they don't - they just need to be used. Try this - make a new stack with 2 buttons. Set the script of the first one to: on mouseUp put 10 into $Test end mouseUp Set the script of the second one to: on mouseUp put $Test end mouseUp Click both buttons in sequence - you get 10 showing up in the message box... so no declarations are necessary, you just use them. Ken Ray Sons of Thunder Software Web site: http://www.sonsothunder.com/ Email: [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Hugh, of course, has been using Jacque's TimeWarp stack since before it existed, and is therefore able to make accurate retroactive predictions. Contradicting him is futile, because he will then go back and change the timeline, and then where will you be, eh? I *knew* there was a reason I was having so much trouble debugging that stack. Hugh, lay off. Aww. And I was having so much fun messing with the temporal directive, too. Okay. Consider me layed. Or laid (another good reason to mess with the temporal directive). And before anyone suggests it, NO... I did not screw up the server on Friday (I just went back and checked). This does not mean, however, that I won't go back in the future into the past and undo what I didn't do in this time line. /H FLCo ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On 10/5/06 8:56 PM, J. Landman Gay [EMAIL PROTECTED] wrote: Robert Sneidar wrote: The benefit would be that I could use the state of the global to determine if this was the first time it had been initialized and run some setup code. The natural state of certain globals is empty, so I couldn't simply test for that. If I were coding from scratch I would just work around this, but I am porting business logic from another dev environment. They use this extensively. Maybe you could fudge it by initializing all the globals to the string NULL. Then check for that. Then you'd just have to add quotation marks around all the NULLs in the existing code. Actually, since the null value is supported, and since you can't initialize a global with a value anyway (can't do global myGlob = 4), you'd have to assign a value anyway, so why not null: global gMyGlob put null into gMyGlob Anyway, that's my 2 cents, Ken Ray Sons of Thunder Software Web site: http://www.sonsothunder.com/ Email: [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Unless someone saw you do it. Did you make a noise? Cheers, Luis. On 8 Oct 2006, at 12:36, [EMAIL PROTECTED] wrote: Hugh, of course, has been using Jacque's TimeWarp stack since before it existed, and is therefore able to make accurate retroactive predictions. Contradicting him is futile, because he will then go back and change the timeline, and then where will you be, eh? I *knew* there was a reason I was having so much trouble debugging that stack. Hugh, lay off. Aww. And I was having so much fun messing with the temporal directive, too. Okay. Consider me layed. Or laid (another good reason to mess with the temporal directive). And before anyone suggests it, NO... I did not screw up the server on Friday (I just went back and checked). This does not mean, however, that I won't go back in the future into the past and undo what I didn't do in this time line. /H FLCo ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On 10/5/06 4:53 PM, Robert Sneidar [EMAIL PROTECTED] wrote: The benefit would be that I could use the state of the global to determine if this was the first time it had been initialized and run some setup code. The natural state of certain globals is empty, so I couldn't simply test for that. If I were coding from scratch I would just work around this, but I am porting business logic from another dev environment. They use this extensively. Try usingthe globalNames -script lines -- global gGlobalNameArr on preopenStack put the globalNames into listToRegister repeat for each item GBLNM in listToRegister get GBLNM_ if it is gGlobalNameArr_ then next repeat do global GBLNM --need this to declare for this handler if char 1 to 4 of it is gRev then next repeat if char 1 of it is $ then next repeat do put GBLNM into gGlobalNameArr[it] end repeat end preopenstack --the gGlobalNameArr array is a global --now the keys of the arr = the list of (global names_) --the values = the startup value of the globals, except gGlobalNameArr --whenever you process a global, compare to gGlobalNameArr[GBLNM_] --the reason for the _ is that the 'do' cmd will interpret the global rather than use its name in the index of the array. --because gGlobalNameArr is declared in the same script container, it does not have to be May not be what you need, but thought it might help. Jim Ault Las Vegas On Oct 5, 2006, at 11:20 AM, J. Landman Gay wrote: On the other hand, just declaring a global automatically initializes it to empty, so maybe that's enough for the original poster. I don't see too much difference between empty and NULL; there's a slight difference but probably not one that would matter too much in most cases. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Declaring initialised globals is not supported, so global gAGlobal is fine, but global gAGlobal=empty throws an error. I can think of three ways to accomplish this: Test against prior usage... if gAGlobal is not among the items of the globals then global gAGlobal put 10 into gAGlobal end if Test against contents... global gAGlobal if gAGlobal then put 10 into gAGlobal ReInitialize... delete global gAGlobal global gAGlobal /H Robert, though this has nothing to do with type-checking, you can initialise variables to whatever you like when you declare them, so global gAGlobal = empty I for one would like to be able to have the option of having new global variables initialized with NULL or UNDEFINED or something, so that I can check for the first time initialization of said variables. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
You're right. I hadn't ever tried this, so assumed that you could initialise on declaration like you can with script locals...seems a bit inconsistent. Best, Mark On 5 Oct 2006, at 17:42, [EMAIL PROTECTED] wrote: Declaring initialised globals is not supported, so global gAGlobal is fine, but global gAGlobal=empty throws an error. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Hugh, you're pushing it a bit... HC didn't appear until 1987...unless you're counting MacPaint and MacDraw! Moi? Unknown? This indicates I should be posting more frequently! /H aka Hugh Senior, developer in HC, then SC, then MC and Rev, since 1984 (now feeling old) -- stephen barncard s a n f r a n c i s c o - - - - - - - - - - - - ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Robert- Wednesday, October 4, 2006, 5:47:16 PM, you wrote: I think this underscores the need for REAL type checking. I was told that a positive integer would return true if is a date is used. BZ #2783 -- -Mark Wieder [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
[EMAIL PROTECTED] wrote: Declaring initialised globals is not supported, so global gAGlobal is fine, but global gAGlobal=empty throws an error. On the other hand, just declaring a global automatically initializes it to empty, so maybe that's enough for the original poster. I don't see too much difference between empty and NULL; there's a slight difference but probably not one that would matter too much in most cases. -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On Oct 5, 2006, at 11:35 AM, Mark Wieder wrote: Wednesday, October 4, 2006, 5:47:16 PM, you wrote: I think this underscores the need for REAL type checking. I was told that a positive integer would return true if is a date is used. BZ #2783 People have created interesting bugs related to types in languages with strong typing. Many languages have type integer which is not an integer but some uniform representation of some subset of integer. Suppose some number in a program should only be a prime. Should a prime type be invented? Some languages infer types. Types are a hint to compilers and in some languages are a ball and chain to the compiler. Types allow a developer to organize thoughts and to catch errors. However, types are part of a more general mechanism related to constraints on the ranges and domains functions and commands. This mechanism might involve good comments, runtime assertions, assertions for analysis, assertions for compiling, and typing. This can be generalized to I/O and sometimes intermediate values. In this particular case, the common Revolution approaches are 1. to comment constraints or 2. to check for value errors and do something about those. In functions I use internally, I usually use comments to describe the sets of allowed values for parameters. In functions made available to customers, I use one or both. Sometimes, I am pretty casual about what a parameter might be. Revolution lends itself to runtime assertions and I expect that many folks have rolled their own. The detailed syntax of Revolution is poorly defined, but I would not be surprised if someone someday creates a smart lint that can handle simple proofs. That may be a while. I would not be surprised if the compiler might catch more in the future based on ranges of values. As far as 'is a date', I tried 'dinner and movie is a date' in the message box and got false, so 'is a date' might be built with an assumption of a specific meaning for 'date'. I have enjoyed strong types in programming, but I don't think typing is what is needed here. Dar ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Stephen- Thursday, October 5, 2006, 7:33:54 AM, you wrote: Hugh, you're pushing it a bit... HC didn't appear until 1987...unless you're counting MacPaint and MacDraw! Hugh, of course, has been using Jacque's TimeWarp stack since before it existed, and is therefore able to make accurate retroactive predictions. Contradicting him is futile, because he will then go back and change the timeline, and then where will you be, eh? -- -Mark Wieder [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Ah, but would the variable be initialized to that value every time I declared it? For Globals this would be a disaster. I will check that out. Bob Sneidar IT Manager Logos Management Calvary Chapel CM On Oct 4, 2006, at 7:00 PM, Mark Smith wrote: Robert, though this has nothing to do with type-checking, you can initialise variables to whatever you like when you declare them, so global gAGlobal = empty local aLocal = null Best, Mark ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Except that negative and real numbers are numbers too! Bob Sneidar IT Manager Logos Management Calvary Chapel CM On Oct 4, 2006, at 7:11 PM, Mark Smith wrote: I think this can be simpler: return (pValue is an integer) AND (pValue = 0) ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Mark Wieder wrote: Stephen- Thursday, October 5, 2006, 7:33:54 AM, you wrote: Hugh, you're pushing it a bit... HC didn't appear until 1987...unless you're counting MacPaint and MacDraw! Hugh, of course, has been using Jacque's TimeWarp stack since before it existed, and is therefore able to make accurate retroactive predictions. Contradicting him is futile, because he will then go back and change the timeline, and then where will you be, eh? I *knew* there was a reason I was having so much trouble debugging that stack. Hugh, lay off. -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
The benefit would be that I could use the state of the global to determine if this was the first time it had been initialized and run some setup code. The natural state of certain globals is empty, so I couldn't simply test for that. If I were coding from scratch I would just work around this, but I am porting business logic from another dev environment. They use this extensively. Bob Sneidar IT Manager Logos Management Calvary Chapel CM On Oct 5, 2006, at 11:20 AM, J. Landman Gay wrote: On the other hand, just declaring a global automatically initializes it to empty, so maybe that's enough for the original poster. I don't see too much difference between empty and NULL; there's a slight difference but probably not one that would matter too much in most cases. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Robert Sneidar wrote: The benefit would be that I could use the state of the global to determine if this was the first time it had been initialized and run some setup code. The natural state of certain globals is empty, so I couldn't simply test for that. If I were coding from scratch I would just work around this, but I am porting business logic from another dev environment. They use this extensively. Maybe you could fudge it by initializing all the globals to the string NULL. Then check for that. Then you'd just have to add quotation marks around all the NULLs in the existing code. -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Overkill solution... function isPositiveInteger pValue replace comma with empty in pValue # Thousands separator replace $ with empty in pValue # Currency identifier try add 1 to pValue catch errnum return false # Not a number end try if trunc(pValue) pValue then return false # Not an Integer return pValue = 1 # Is not negative end isPositiveInteger Underkill solution... function isPositiveInteger pValue return (pValue is a number) AND (pValue =0) AND (trunc(pValue)=pValue) end isPositiveInteger /H ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
/H- However, these return conflicting values if pValue is empty. So I suppose the question to ponder is is empty a positive integer? -- -Mark Wieder [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Re, I agree. Actually, I had written a long time ago an universal function, able to handle any combination of any length. One argument only: something like the strings I used in the tutorial as an introduction to specific formats. But you have to understand well how to specify the format and it makes things a bit more complicated for anyone :-) And the stack I have released is a simple tutorial to get any user started... So I did no include it ;-) Le 4 oct. 06 à 21:55, Francis Nugent Dixon a écrit : Hi Eric, I totally agree ! Pre 1980 Data Processing (that was what it was called in those days) spent eons vetting, rejecting and finally . integrating external data. Things changed later, when the idea of checking Data Entry at the source was born ! Of course, this was only possible after the introduction of independant (non-centralized) systems. I think we all agree that you should not let sht enter the system, then you won't have to spend time fleecing it out. So . Can we now have the all singing - all dancing data entry routine, with a call sequence like : put dataentry(x,y) into myreceptionfield where x is the type of check required, and y is the length to be accepted .. ? unless, of course, you can think of more criteria . This routine could be integrated into your nice Managing Entry Boxes stack. However, the equally elegant solution from our unknown [EMAIL PROTECTED] user is also interesting : function isPositiveInteger pValue return (pValue is a number) AND (pValue =0) AND (trunc(pValue) =pValue) end isPositiveInteger Best Regards from Paris, Eric Chatonet -- http://www.sosmartsoftware.com/[EMAIL PROTECTED]/ ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
I think this underscores the need for REAL type checking. I was told that a positive integer would return true if is a date is used. As easy as non-typed variables are, it often becomes necessary to check for such things. I for one would like to be able to have the option of having new global variables initialized with NULL or UNDEFINED or something, so that I can check for the first time initialization of said variables. Maybe there could be an addition to the global/local variable declaration so that if you include an arguement and the variable is undefined as of yet, it will initialize the variable with your arguement as in: global bobtest NULL If bobtest already exists it will leave it as is, but if not it will initialize it with the string NULL or whatever you tell it to. sigh if only I ruled the world... Bob Sneidar IT Manager Logos Management Calvary Chapel CM ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Robert, though this has nothing to do with type-checking, you can initialise variables to whatever you like when you declare them, so global gAGlobal = empty local aLocal = null Best, Mark On 5 Oct 2006, at 08:47, Robert Sneidar wrote: I think this underscores the need for REAL type checking. I was told that a positive integer would return true if is a date is used. As easy as non-typed variables are, it often becomes necessary to check for such things. I for one would like to be able to have the option of having new global variables initialized with NULL or UNDEFINED or something, so that I can check for the first time initialization of said variables. Maybe there could be an addition to the global/local variable declaration so that if you include an arguement and the variable is undefined as of yet, it will initialize the variable with your arguement as in: global bobtest NULL If bobtest already exists it will leave it as is, but if not it will initialize it with the string NULL or whatever you tell it to. sigh if only I ruled the world... Bob Sneidar IT Manager Logos Management Calvary Chapel CM ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
I think this can be simpler: return (pValue is an integer) AND (pValue = 0) Obviously, if it's an integer, it's also a number, and in this context it might be better to avoid 'trunc' since in some circumstances, (there is a thread from a while back about this) trunc returns a non-integer result. I'm still not clear on whether zero is positive, though, especially since we can have -0 and +0 apparently, though being mathematically unsophisticated I'd have thought them equal, except to a dumb computer! Best, Mark On 5 Oct 2006, at 01:13, [EMAIL PROTECTED] wrote: function isPositiveInteger pValue return (pValue is a number) AND (pValue =0) AND (trunc(pValue) =pValue) end isPositiveInteger ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Moi? Unknown? This indicates I should be posting more frequently! /H aka Hugh Senior, developer in HC, then SC, then MC and Rev, since 1984 (now feeling old) However, the equally elegant solution from our unknown [EMAIL PROTECTED] user is also interesting : function isPositiveInteger pValue return (pValue is a number) AND (pValue =0) AND (trunc(pValue)=pValue) end isPositiveInteger ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Hi Dom, This is fine if signed and decimal input is allowed; but isn't an adequate check for numerics that must be positive or integers only. if field MyTextField is an integer Still doesn't cut it if the input must be positive. :{`) -- Rob Cozens CCW, Serendipity Software Company And I, which was two fooles, do so grow three; Who are a little wise, the best fooles bee. from The Triple Foole by John Donne (1572-1631) ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
if field MyTextField is an integer and field MyTextField -0.1 Jim Ault Las Vegas On 10/3/06 7:55 AM, Rob Cozens [EMAIL PROTECTED] wrote: Hi Dom, This is fine if signed and decimal input is allowed; but isn't an adequate check for numerics that must be positive or integers only. if field MyTextField is an integer Still doesn't cut it if the input must be positive. :{`) ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On 10/3/06 12:11 PM, Jim Ault [EMAIL PROTECTED] wrote: if field MyTextField is an integer and field MyTextField -0.1 Can't you use just 0 ? if field MyTextField is an integer and field MyTextField 0 or: get fld MyTextField if (it is an integer) and (it 0) :-) Ken Ray Sons of Thunder Software Web site: http://www.sonsothunder.com/ Email: [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Hi Ken, Jim and many others :-) I was following this thread and I had to pinch myself to make sure I wasn't dreaming: From an ergonomics point of view, don't you think that a well thought app may not tell the user: you made a mistake? As for me, I think that all this has to be handled upstream. By allowing to enter only right values in a field, by choosing other ways: lists, calendars, graphics, etc. Just my two cents ;-) May be I miss something? Best Regards from Paris, Eric Chatonet Le 3 oct. 06 à 19:23, Ken Ray a écrit : On 10/3/06 12:11 PM, Jim Ault [EMAIL PROTECTED] wrote: if field MyTextField is an integer and field MyTextField -0.1 Can't you use just 0 ? if field MyTextField is an integer and field MyTextField 0 or: get fld MyTextField if (it is an integer) and (it 0) :-) Ken Ray Sons of Thunder Software Web site: http://www.sonsothunder.com/ Email: [EMAIL PROTECTED] -- http://www.sosmartsoftware.com/[EMAIL PROTECTED]/ ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On Oct 3, 2006, at 12:55 PM, Eric Chatonet wrote: As for me, I think that all this has to be handled upstream. By allowing to enter only right values in a field, by choosing other ways: lists, calendars, graphics, etc. Just my two cents ;-) May be I miss something? You are right! And every valid entry should be meaningful. Thanks for the reminder. Sometimes it is hard to balance responding directly to a list question and to respond with what is really needed. (And for me, I get distracted by things like 0xface being a number.) However, there are some cases that are annoying to the user when handled upstream, such as allowing only words on a vocabulary list. Dar ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On 10/3/06 12:11 PM, Jim Ault [EMAIL PROTECTED] wrote: if field MyTextField is an integer and field MyTextField -0.1 Can't you use just 0 ? if field MyTextField is an integer and field MyTextField 0 or: get fld MyTextField if (it is an integer) and (it 0) I thought that 0 was a valid positive (non-negative) integer, therefore if field MyTextField -0.1 or if field MyTextField -1 but if the requirement is 0 then Ken is right. Jim Ault Las Vegas ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On Oct 3, 2006, at 2:21 PM, Jim Ault wrote: I thought that 0 was a valid positive (non-negative) integer, In the common math jargon, 0 is non-negative, but not positive. Since we are casual around here about words, it is good to ask what a person wants. Fortunately, we have the = operator. Dar ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On 10/1/06 12:25 PM, Mark Wieder [EMAIL PROTECTED] wrote: Francis- Saturday, September 30, 2006, 11:56:36 AM, you wrote: Is this the right way to check for numerics, and if so, what have I done wrong ? Try if field MyTextField is a number Or , if isNumber(fld myTextFld) Hershel ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Francis, Mark, et al: Is this the right way to check for numerics, and if so, what have I done wrong ? Try if field MyTextField is a number This is fine if signed and decimal input is allowed; but isn't an adequate check for numerics that must be positive or integers only. -- Rob Cozens CCW, Serendipity Software Company And I, which was two fooles, do so grow three; Who are a little wise, the best fooles bee. from The Triple Foole by John Donne (1572-1631) ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
True. So we have if fld someTextField is an integer, and we can always test for 0, =0, etc. as required. Best, Mark On 2 Oct 2006, at 16:08, Rob Cozens wrote: Francis, Mark, et al: Is this the right way to check for numerics, and if so, what have I done wrong ? Try if field MyTextField is a number This is fine if signed and decimal input is allowed; but isn't an adequate check for numerics that must be positive or integers only. -- Rob Cozens CCW, Serendipity Software Company And I, which was two fooles, do so grow three; Who are a little wise, the best fooles bee. from The Triple Foole by John Donne (1572-1631) ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Rob Cozens [EMAIL PROTECTED] wrote: if field MyTextField is a number This is fine if signed and decimal input is allowed; but isn't an adequate check for numerics that must be positive or integers only. if field MyTextField is an integer ;-) ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On Oct 2, 2006, at 1:29 PM, Dom wrote: Rob Cozens [EMAIL PROTECTED] wrote: if field MyTextField is a number This is fine if signed and decimal input is allowed; but isn't an adequate check for numerics that must be positive or integers only. if field MyTextField is an integer ;-) Cool. I need to browse through the dictionary. Maybe I need an app like one of those word-a-day vocabulary builders. However, there are interesting things that can sneak through as in these integers: 0x02b1 (hex) 3e0 (exponent notation, similar to scientific notation) 10.00(zero fraction) 100.888 (big number) Of course, there may be times when one wants to allow those integers. Dar ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Francis- Saturday, September 30, 2006, 11:56:36 AM, you wrote: Is this the right way to check for numerics, and if so, what have I done wrong ? Try if field MyTextField is a number -- -Mark Wieder [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
Hi Francis, Perhaps your field doesn't contain a number with a length of 4? I tried this in the message box: put matchtext(1234,[0-9][0-9][0-9][0-9]) and got true returned. Best, Mark -- Economy-x-Talk Consultancy and Software Engineering http://economy-x-talk.com http://www.salery.biz Get your store on-line within minutes with Salery Web Store software. Download at http://www.salery.biz Op 30-sep-2006, om 20:56 heeft Francis Nugent Dixon het volgende geschreven: Hi from Paris, I may be totally dumb, but I am not sure how to use MatchText. I find the explanation in the on-line doc. particularly obscure . I want to check the contents of a field for numeric, so, for a field of four characters, I coded : matchText(field MyTextField,[0-9][0-9][0-9][0-9]) if it is true then .. Is this the right way to check for numerics, and if so, what have I done wrong ? -Francis Nothing should ever be done for the first time ! ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Testing for numerics
On Sep 30, 2006, at 12:56 PM, Francis Nugent Dixon wrote: I want to check the contents of a field for numeric, so, for a field of four characters, I coded : matchText(field MyTextField,[0-9][0-9][0-9][0-9]) if it is true then .. Is this the right way to check for numerics, and if so, what have I done wrong ? Revolution defines matchText as a function. The above script will look for a command named matchText. (An implied 'get' does sound like an interesting idea.) So, first of all, change the above to this: get matchText(field MyTextField,[0-9][0-9][0-9][0-9]) if it is true then .. This is also OK, if you are content with the readability: get matchText(field MyTextField,[0-9][0-9][0-9][0-9]) if it then .. Or this: if matchText(field MyTextField,[0-9][0-9][0-9][0-9]) then .. That will match text that contains 4 digits in a row and so will match around 1966 or so or 4/5/1966. Perhaps this does what you want: if matchText(field MyTextField,\A[0-9]{4}\z) then .. The \A and \z match at the start and end respectively. The {4} means exactly 4 times. You might want to consider is a number. Use it like this: if field MyTextField is a number then .. That will match some numerals that you might not expect, such as 1.3, 1.0E01, +inf (on OS X) and 0xF0E. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution