Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: Overloaded on December 06, 2012, 07:50:47 PM
-
Hey,
Is there a way to display the whole number value (integer?) only in a %.0f DRO without rounding up to the next digit ?
For example:
Put 2 DRO's on screen w/the same OEM or User Code.
Set #1 as 4 decimal place, and #2 as 0 decimal places.
If #1 shows 1.8, #2 will round up to 2
How can I capture just the whole number in #1.
Possible ?
Thanks
-
Use a User DRO for the integer, and use the macropump to read the other DRO, trim off the decimals, and write to the User DRO.
Not terribly elegant, but it should work, no?
-
Ha ... sounds quite elegant !
How do I trim with the pump ?
Example ? ? ?
Thanks Ger
Russ
-
The interger function from what I see in Machscreen is broken. You get some weird number displayed.
IF you are populating a User dro then you could ROund down the number then send to the DRO .
OEMDROs most are control by the screen format.
(;-) TP
-
IF you are populating a User dro then you could ROund down the number then send to the DRO .
Yep ... User DRO. How can I round it dwn internally ?
Doing it manually now, gotta be a better way.
Both of you are encouraging.
Reading VB stuff now.....a lot like chineese ::)
-
I found this, but can't seem to relate it to "our" language.
http://www.vbforums.com/showthread.php?379158-How-to-Remove-Decimal-Part
-
... and this in the Mach book.
What would the proper syntax be ? ? ?
Wish I had a better grip on this.
Thanks
-
Place something like this in the macropump macro.
DROInteger=CStr(GetOemDro(xx))
Length = Len(DROInteger)
For X = 1 To Length Step 1
lstring=Left(DROInteger,X)
If Right(lstring,1) = "." Then
NewLength = x-1
Exit For
End If
Next X
WholeNo=CInt(Left(DROInteger, NewLength))
SetOemDRO(xx)
-
Hi Ger,
tried it, not working.
Changed OEM to User ... no difference.
Here it is :
DROInteger=CStr(GetUserDro(1107))
Length = Len(DROInteger)
For X = 1 To Length Step 1
lstring=Left(DROInteger,X)
If Right(lstring,1) = "." Then
NewLength = x-1
Exit For
End If
Next X
WholeNo=CInt(Left(DROInteger, NewLength))
SetUserDRO(1106)
Getting "ERROR on line: 24 - Argument not optional"
-
Oops.
Try SetUserDRO(xx, WholeNo)
-
That works ... sort of.
Stepping through w/the editor is OK.
Won't run on its own.
There is more in the pump. Care to take a look ? Might need some waits in there. ?
Thanks Ger,
Russ
MaxStroke = GetUserDRO (1105)
CutLength = GetUserDRO (1100)
SawKerf = GetUserDRO (1104)
NumberOfCuts = GetUserDRO (1106)
Divider = GetUserDRO (1107)
' This divides the available stroke by the Feed Increment
SetUserDRO (1107,MaxStroke / (CutLength + SawKerf) )
' This rounds it down to the nearestWhole number of Increments
DROInteger=CStr(GetUserDro(1107))
Length = Len(DROInteger)
For X = 1 To Length Step 1
lstring=Left(DROInteger,X)
If Right(lstring,1) = "." Then
NewLength = x-1
Exit For
End If
Next X
WholeNo=CInt(Left(DROInteger, NewLength))
SetUserDRO(1106,WholeNo)
-
Try
DROInteger=CStr(MaxStroke / (CutLength + SawKerf))
That way you're not trying to read the DRO right after you right to it.
I don't know if you can wait in a macropump, because you don't have much time.
-
not quite right yet Ger.
Last suggestion did not work at all, even commented out the previous code and stepping through.
Back as it was, steps through OK but won't run auto.
Russ
-
Try SetUserDro(##, Fix(GetOemDro(##) ) ' Where the ## are the DRO numbers
Just a thought, (;-) TP
-
I was playing with Fix in the editor and it kept giving me bad syntax errors, and I couldn't figure it out.
-
IF you are going to use the macro pump you need to loop out IF the 2 dros are the same number to prevent all the overwriting going on THAT eats up processor time.
(;-) TP
-
Tried TP's w/ Fix and Int ...neither worked.
Tried these plus Ger's in a button. So as to not conflict with the pump
Ger's worked 1 time, the returned a 0
-
Here's what I HAVE running in the macropump here.
Works fine tracks the Xdro exactly to the whole number. The IF statement checks to see IF the 2 values are the same if they are then it ends otherwise it writes thenew value to the UserDRO(1555).
If Fix(GetDro(0)) = GetUserDro(1555) Then
End
End If
SetUserDro(1555, Fix(GetDro(0)))
While Ismoving()
Wend
End
-
That works fine in a Button,( after changing all to UserDRO's) but it wont run in my pump along with the other line.
Might just have to leave it in a button ? ? ? Just 1 extra step I was trying to avoid.
Thanks TP
MPmp
MaxStroke = GetUserDRO (1105)
CutLength = GetUserDRO (1100)
SawKerf = GetUserDRO (1104)
NumberOfCuts = GetUserDRO (1106) 'Interger, actual cut increments
Divider = GetUserDRO (1107) 'raw decimal # xx.*********x
' This divides the available stroke by the Feed Increment
SetUserDRO (1107,MaxStroke / (CutLength + SawKerf) )
'TP's Goody....................
If Fix(GetUserDro(1107)) = GetUserDro(1106) Then
End
End If
SetUserDro(1106, Fix(GetUserDro(1107)))
While Ismoving()
Wend
End
-
Thanks Guys for the points to the right direction.
Can it possibly be this simple ? ??
This one line does it all ... perfectly , so far.
SetUserDRO(1106,Fix(GetMaxStroke)/(CutLength+SawKerf))
Right in the pump, no button needed.
Fingers crossed.
Thanks again !
Russ
-
You are the one Driving the boat you tell US. We just throw rocks at you to keep you rowing (;-)
(;-) TP
-
WELL did it work???
(;-)TP
-
It did for a while. Started getting goofy. Intermittent, yhen gradually crapped out entirely.
Ended up with no Pump at all ... put it all in 1 button.
1 line does the math, the next line FIX's the integer to the requested DRO.
CutLength = GetUserDRO (1100)
SawKerf = GetUserDRO (1104)
MaxStroke = GetUserDRO (1105)
SetUserDRO(1107,MaxStroke/(CutLength + SawKerf))
SetUserDRO(1106,Fix (GetUserDRO(1107)))
Tried for hours and cannot make it fail.
Would be nice to have it update automatically in the pump, but this will be OK.
Thanks Guys
Russ
-
I think you need to find out WHY your PUMP is failing. That cannot be a good thing. Here those routines have been running since yesterday without a problem.
(;-) TP
-
One thing I noticed, is it possible that it might be goofy acting if the Screen Designer is left running ?
I tried sooooooooooooooo many things last night, I may have confused it. Had Macro's disappearing and saving where the shouldn't be, multiple editors open .... might try again fresh later.
Thanks TP
Oh, and BTW ....
For an experiment, I left the 1 line for the math in the pump and assigned Ger's script to a button, TP's script to another button and some cobbled up script of my own to another button.
All/any of the 3 buttons worked fine ... every time.
Just never could get both functions to play together in the pump.
Went to bed this morning w/a headache, woke up w/a hangover.
-
DO NOT run with multiple editors OPEN it can be a really BAD thing. Leaned that the hard way long ago. SAME with MachScreen Close it before you load mach3.
I did not mean to hit you in the head with one of the rocks BUT Gerry may have (;-)
(;-) TP
-
;D
I'll blame you both. >:D
One hit me in the head .... and another went through the floor of the boat. :D
Anxious to try again.
Mind to paste me the EXACT file you have running in the pump ? ::)
Thanks,
Russ :)
-
I m not at that PC right now but it is the same code listed above.
If Fix(GetDro(0)) = GetUserDro(1555) Then
End
End If
SetUserDro(1555, Fix(GetDro(0)))
While Ismoving()
Wend
End
-
OK, i'll try it again later tonight.
Keep in mind tho .... there's that other line in the pump that does the math for the dro's.
The scripts must work together, I think this is where I had the problems.
Thanks
-
This might work (as I pick up another rock (;-) ) IF you did not need to visually see/update the DRO(1107) then it could be even simpler AND faster to execute. By th ewy what VERSION of mach3 are you running ?
If Fix (GetUserDro(1105)/(GetUserDro(1100) + GetUSerDro(1104))) = GetUserDro(1106) Then
End
End If
SetUserDRO(1107,(GetUserDro(1105)/(GetUserDro(1100) + GetUSerDro(1104))))
While Ismoving()
Wend
SetUserDRO(1106,Fix (GetUserDRO(1107)))
While Ismoving()
Wend
End
-
Curiously, I started fresh, put this back in the pump and it works like a charm.
This went crazy later on (yesterday) but might now know why.
MaxStroke = GetUserDRO (1105)
CutLength = GetUserDRO (1100)
SawKerf = GetUserDRO (1104)
SetUserDRO (1107,MaxStroke / (CutLength + SawKerf))
SetUserDRO(1106,Fix(GetUserDRO (1107)))
Almost identical to your's TP, does it need the "If" and the Waits ?
NONE of these DRO's (1100,4 & 5) are moving, like an axis ... they are all fixed user entered values.
Task: See if you can get a SINGLE line script to do what the 2 lines above do.
This is what I thought I had working yesterday that crapped out on me. My "Simple" sample a few posts back.
Will be back later ........
Russ
-
Using R3.043.022
-
Without the check loop it continuously writes the DRO. With the loop IF the value has not changed it just exits saving the time slice of the write.
yes a single line your way or 2 lines my way(checkloop) should work just fine.
(;-) TP
-
That is about as short as I can get it dependable.
SetUserDRO(1106,Fix (GetUserDro(1105)/(GetUserDro(1100) + GetUSerDro(1104))))
While Ismoving()
Wend
End