Dave,
What if someone lays a book on the ESC key? What happened to the previous setting of ON ESCAPE? What if you want all applications to use F10 instead of ESC?
Of course, if you don't believe in resuable code, that's cool.
Tony
You can add this to your loop to allow it to be ended (interrupted) by pressing the escape key.
*___________________________________________________________________
** CANCEL OBJECT CLASS
* Version = 1.0
* Copyright (C) 2002 Vignone...
Some time ago, I wrote a DOS program that reads a dbf and outputs a space delimited text file. You could then modify it an import it into a new dbf.
If you would give me your email address, I can send you the EXE.
Tony
Wayne,
No, a little longer. I love a challenge.
You might what to improve in the two routines that get the 3rd reel, getLargeThird and getAnyThird. They should get one that is closer to the size of the smaller or a multiple of the smaller or ... anything else that you can think of.
Tony
...glich - % scraped comes out to 11%
Tony
clear
reelLens = "985,580,450,345,275,265,230,190,150"
Reels = NEWOBJECT("Reel")
Reels.Make(reelLens)
*----- Braid reels -----------
do while .T.
if Reels.Count() >= 3 then
* find 2 reel with minimum difference (except largest)...
...an array element (aDelete).
local i,j,p,reel,reelLens,scrap
dimension reel(1)
reelLens = "985-1,580-2,450-3,345-4,275-5,265-6,230-7,190-8,150-9"
* NOTE: reelLens ::= length-reelNumber
scrap = 0
clear
*----- Load reels -----------
i = 1
p = at(",",reelLens)
if p = 0 then
p =...
Wayne,
My first thoughts are for the invariant of a loop.
Let's see ... we want always to braid two reels with minimum difference with a third reel that is 100' longer than the shortest of the first two. In your example, that would be 265 and 275 (leaving scrap of 10') braided with any other...
Alex,
Your problem is written in VB, However, here's the VFP version that works. I tried it with a 2x2 array.
*Setup an example
dimension strArray(2,2)
strArray(1,1) = "AAA"
strArray(1,2) = "BBB"
strArray(2,1) = "CCC"
strArray(2,2) = "DDD"
store 2 to endrow,endcol
*Run the Test
strOut = ""...
Dave,
Good show! If you put in 4.9811 with DECIMALS 4 you get back 4.98109961 and int(4.98109961*10^5) = 498109.
Voila!
It looks like assigning 4.9811 to a variable causes it to be stored internally as Single Precision Hex:409f652b which is 4.98109961 when DECIMALS is 4 and 4.9811 when...
...results proving that INT is a Microsoft special math function - Hungarian Math, maybe??
Avoid the INT function!
SET DECIMALS TO 4
FOR l_nNewValue = 4.9810 to 4.9815 step .0001
? l_nNewValue
? l_nNewValue*(10^5)
? INT(l_nNewValue*(10^5))
? INT(round(l_nNewValue,4)*(10^5))
ENDFOR
Tony
INT must respect the mathematical meaning not the internal problem of representing integers with binary numbers. When a binary result translates to 44.99999999999999...etc, the compiler should realize that it is 45 not the floor, 44.
Tony
Dave,
You are right, the INT function is incorrect. INT(l_nNewValue*(10^5)) is returning the FLOOR since the result must be a smidgen below 498110 (in binary). It should be returning the CEILING.
I tried the same program in TRU BASIC which is a mathematical language (compiler written by...
Mike:
I understand you situation. I am not bound by clients.
Neil and Craig:
Taking Craig's example,
Not necessarily apparent unless all variables and functions are stongly typed. If they are not and are polymorphic, then it actually obfuscates.
Say, gcY = date() and...
Stella740pl is right...
However, str(number,16) will not display decimals if there are any. It displays integers only (positive and negative whole numbers)
?str(-12345678.8765,16) displays -12345679
It rounds also, and curiously. It rounds the absolute value!
Tony
...ones. The local ones are usually defined at the beginning just as we do with LOCAL and PRIVATE.
I'd rather see...
local firstVar,otherVar
* where firstVar is a number in range [2:reccount()] and...
* otherVar is a filename with extention DBF
...than
local...
Mike
But, he didn't. That's the idea. No program part (subroutine or function, with it's local variables) need be more than half a page. If it is, then good structured and object oriented programming practices are being violated. I cant imagine that you are coding a method with 5000 lines...
Bill,
I appreciate you input. When I do 'mathy' things, I prefer standard math/science variable names (v velocity, m mass, theta angle, etc.)
But you are right when we are in the database manipulation arena.
And, thanks for reminding me about the m-dot issue.
Tony
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.