Working in Inches

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Re: Working in Inches

Post by bidgeeman » Tue Jul 18, 2017 6:59 am

Hi bogs.
Many thanks to you! It worked it out to .222 sets a pixel perfectly to a 1/16th of an inch.
There are two fields. One field is where you type in "Inches" and this field is processed by:

Code: Select all

   put fld "Inches"  /  0.222 into Hloc
multiply Hloc by 16
The second field is for 16ths and is processed by:

Code: Select all

   put fld "16ths"  /  0.222 into HlockB
   set the left of graphic "Box"  to Hlock + HlockB
This works perfectly but I need a way to limit the field for 1/16ths of an inch to "16".
Is there a way to do this that prevents the user typing in a value over 16?

Thanks again for all the great help on this forum.
Bidge

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Working in Inches

Post by richmond62 » Tue Jul 18, 2017 8:59 am

defff.png
Defocussed.livecode.zip
Here's the stack
(27 KiB) Downloaded 201 times
SORRY: I'd better go and sort out a second cup of coffee. :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Working in Inches

Post by richmond62 » Tue Jul 18, 2017 9:23 am

Is there a way to do this that prevents the user typing in a value over 16?
I really don't know how you could do that as the user types for the simple
reason that the user will not type "16" s/he will type "1" and then "6".

I suppose you could have a routine to see if the user types 1 or 2 glyphs and then,
if they type 2, check what the second one is . . . .

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Working in Inches

Post by richmond62 » Tue Jul 18, 2017 9:36 am

curt.png
Curtailer.livecode.zip
Here's the stack
(1.08 KiB) Downloaded 198 times

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Re: Working in Inches

Post by bidgeeman » Tue Jul 18, 2017 10:22 am

That stack taught me two things thank you richmond62 :)
The code was perfect but "ask" commend I had not come across yet.
I have often wondered how you could make a pop up screen that asks
"Do you want to continue? Yes or No".
How do you script in button for yes or no in the a"ask" function?



EDIT: Ahh...I found this:)

Code: Select all

answer "Go ahead?" with "Yes" or "No" or "Maybe"


But...I guess you need to put in an "if then" to proceed?
I'll have a play. This is so much fun!

Thank you again :)
Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Re: Working in Inches

Post by bidgeeman » Tue Jul 18, 2017 11:45 am

Hi richmond62
Is it possible to apply your curtailer code directly into a text field rather than a button?
I'm not sure what the command is if there is one?

Thanks
Bidge

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Working in Inches

Post by bogs » Tue Jul 18, 2017 3:11 pm

bidgeeman wrote: This works perfectly but I need a way to limit the field for 1/16ths of an inch to "16".
Is there a way to do this that prevents the user typing in a value over 16?
The only thing I can think of (but I just woke up, so take it with a grain of granite) would be something like

Code: Select all

if char 2 of field "yourFieldNameToCheck" > 6 then {rest of your code to show the message, blank the box, etc here}
You'd have that fire (ideally) either after they leave the field, or before they can type or click anywhere else , sorry, not awake enough to give a more coherent response :|

**Edited to correct logic errors pointed out to me by Craig, who was awake today :mrgreen:
Last edited by bogs on Wed Jul 19, 2017 1:16 am, edited 2 times in total.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Working in Inches

Post by richmond62 » Tue Jul 18, 2017 6:13 pm

Dunno how "char 2" could be bigger than 16 . . .

How about this:

if (char 1 of fld "XXX" is "1") and (char 2 of fld "XXX" > 6) then
put "Too big, my friend" into fld "XXX"
end if

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Working in Inches

Post by bogs » Tue Jul 18, 2017 8:19 pm

richmond62 wrote:Dunno how "char 2" could be bigger than 16 . . .
That is because you skipped over this part
bogs wrote:The only thing I can think of (but I just woke up, so take it with a grain of granite)
You are correct, in your correction, just verify char 1 is < 2, and char 2 is < 7 :lol: I say char 1 less than 2 because it could easily be "0", as in "05".

**Edited to correct logic errors pointed out to me by Craig, who was awake today :mrgreen:
Last edited by bogs on Wed Jul 19, 2017 1:16 am, edited 2 times in total.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Working in Inches

Post by dunbarx » Tue Jul 18, 2017 8:50 pm

Only glancing at this thread now and again, but am intrigued by the statements:
if char 2 of field "yourFieldNameToCheck" > 16...

...and char 2 is < 17
Maybe I am out of the loop, but...

Craig

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Working in Inches

Post by bogs » Tue Jul 18, 2017 10:59 pm

Who am I? Who are you? What forum is this ?!?! :lol: noted and corrected. It was a pretty bad day all round for me :oops:
Image

Post Reply