Clear Data Input Button..?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Clear Data Input Button..?

Post by bn » Tue Jan 12, 2010 7:15 pm

topcat,
I forgot one end if in the previous post
this is the corrected version:

Code: Select all

on mouseup
   
   if the target contains "button" then
      put the label of the target into tLabel
      
      -- test for your range of interest
      -- between 0 and 36 and only then do the following
      if tLabel >-1 and tLabel < 37 then
         
         -- do your field shuffling before putting 
         -- the new value into "fld1" otherwise the new value would 
         -- be shifted to fld2 every time
         put field "fld3" into field "fld4"
         put field "fld2" into field "fld3"
         put field "fld1" into field "fld2"
         
         if tLabel = 0 then put "Z" into field "fld1"
         if tLabel > 0 and tLabel < 13 then put "L" into field "fld1"
         if tLabel > 12 and tLabel < 25 then put "M" into field "fld1"
         if tLabel > 24 and tLabel < 37 then put "H" into field "fld1" 
         
         put field "lastNum17" into field "lastNum18"
         put field "lastNum16" into field "lastNum17"
         put field "lastNum15" into field "lastNum16"
         put field "lastNum14" into field "lastNum15"
         put field "lastNum13" into field "lastNum14"
         put field "lastNum12" into field "lastNum13"
         put field "lastNum11" into field "lastNum12"
         put field "lastNum10" into field "lastNum11"
         put field "lastNum9" into field "lastNum10"
         put field "lastNum8" into field "lastNum9"
         put field "lastNum7" into field "lastNum8"  
         put field "lastNum6" into field "lastNum7"
         put field "lastNum5" into field "lastNum6"
         put field "lastNum4" into field "lastNum5"  
         put field "lastNum3" into field "lastNum4"
         put field "lastNum2" into field "lastNum3"
         put field "lastNum1" into field "lastNum2"
         put tLabel into field "lastNum1" 
      else
         --
         -- if you have anything that should happen if 
         -- tLabel outside of 0 .... 36 then insert it here 
         -- or delete the else part
      end if
end mouseUp
sorry about that
regards
Bernd

topcat888
Posts: 44
Joined: Sat Jan 02, 2010 8:10 pm

Re: Clear Data Input Button..?

Post by topcat888 » Tue Jan 12, 2010 7:26 pm

Hi Bernd

Using that code it does what it used to do, which is clear field 1 then enter new number via number keypad (all good so far) BUT then the blank moves to field 2 whilst the new number is inserted into field 1... Basically the blank moves along the row of fields...Exactly what we had before. Try it, create four text fields (fld1 > fld4) and a few buttons to enter any numbers from 1 to 36 and a clear button (put empty into field "fld1")

Thanks

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Clear Data Input Button..?

Post by bn » Tue Jan 12, 2010 7:39 pm

topcat
try this

Code: Select all

on mouseup
   
   if the target contains "button" then
      put the label of the target into tLabel
      
      -- test for your range of interest
      -- between 0 and 36 and only then do the following
      if tLabel >-1 and tLabel < 37 then
         
         -- do your field shuffling before putting 
         -- the new value into "fld1" otherwise the new value would 
         -- be shifted to fld2 every time
         if not (field "fld1" = empty) then -- only shift when fld1 not empty
            put field "fld3" into field "fld4"
            put field "fld2" into field "fld3"
            put field "fld1" into field "fld2"
         end if
         
         if tLabel = 0 then 
            put "Z" into field "fld1"
         end if
         if tLabel > 0 and tLabel < 13 then 
            put "L" into field "fld1"
         end if
         if tLabel > 12 and tLabel < 25 then
            put "M" into field "fld1" 
         end if
         if tLabel > 24 and tLabel < 37 then
            put "H" into field "fld1" 
         end if
         
         --         put field "lastNum17" into field "lastNum18"
         --         put field "lastNum16" into field "lastNum17"
         --         put field "lastNum15" into field "lastNum16"
         --         put field "lastNum14" into field "lastNum15"
         --         put field "lastNum13" into field "lastNum14"
         --         put field "lastNum12" into field "lastNum13"
         --         put field "lastNum11" into field "lastNum12"
         --         put field "lastNum10" into field "lastNum11"
         --         put field "lastNum9" into field "lastNum10"
         --         put field "lastNum8" into field "lastNum9"
         --         put field "lastNum7" into field "lastNum8"  
         --         put field "lastNum6" into field "lastNum7"
         --         put field "lastNum5" into field "lastNum6"
         --         put field "lastNum4" into field "lastNum5"  
         --         put field "lastNum3" into field "lastNum4"
         --         put field "lastNum2" into field "lastNum3"
         --         put field "lastNum1" into field "lastNum2"
         --         put tLabel into field "lastNum1" 
         
         --
         -- if you have anything that should happen if 
         -- tLabel outside of 0 .... 36 then insert it here 
         -- or delete the else part
      end if
   end if
end mouseUp
now if fld1 is empty then the fields are not shifted and a new value is put into field fld1. If field fld1 is not empty than the values are shifted
is that it?
regards
Bernd

topcat888
Posts: 44
Joined: Sat Jan 02, 2010 8:10 pm

Re: Clear Data Input Button..?

Post by topcat888 » Tue Jan 12, 2010 7:54 pm

Hi Bernd,

Yes.! thats it thankyou. The only thing is the numbers entered into the lastNum fields (fields 1-18) do the same 'blank moving along' the fields thing..?

Did you rem them out for a reason..?

Thanks

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Clear Data Input Button..?

Post by bn » Tue Jan 12, 2010 8:02 pm

topcat,
I remed them out because I was too lazy to make the fields in the first place... :)
I moved that part up, see comments.
Hope I got it right.

Code: Select all

on mouseup
   
   if the target contains "button" then
      put the label of the target into tLabel
      
      -- test for your range of interest
      -- between 0 and 36 and only then do the following
      if tLabel >-1 and tLabel < 37 then
         
         -- do your field shuffling before putting 
         -- the new value into "fld1" otherwise the new value would 
         -- be shifted to fld2 every time
         if not (field "fld1" = empty) then -- only shift when fld1 not empty
            put field "fld3" into field "fld4"
            put field "fld2" into field "fld3"
            put field "fld1" into field "fld2"
            
            -- moved this here since it seems to be 
            -- the same as above for fld1-fld4
            -- only if fld1 is not empty
            put field "lastNum17" into field "lastNum18"
            put field "lastNum16" into field "lastNum17"
            put field "lastNum15" into field "lastNum16"
            put field "lastNum14" into field "lastNum15"
            put field "lastNum13" into field "lastNum14"
            put field "lastNum12" into field "lastNum13"
            put field "lastNum11" into field "lastNum12"
            put field "lastNum10" into field "lastNum11"
            put field "lastNum9" into field "lastNum10"
            put field "lastNum8" into field "lastNum9"
            put field "lastNum7" into field "lastNum8"  
            put field "lastNum6" into field "lastNum7"
            put field "lastNum5" into field "lastNum6"
            put field "lastNum4" into field "lastNum5"  
            put field "lastNum3" into field "lastNum4"
            put field "lastNum2" into field "lastNum3"
            put field "lastNum1" into field "lastNum2"
            put tLabel into field "lastNum1" 
         end if
         
         if tLabel = 0 then 
            put "Z" into field "fld1"
         end if
         if tLabel > 0 and tLabel < 13 then 
            put "L" into field "fld1"
         end if
         if tLabel > 12 and tLabel < 25 then
            put "M" into field "fld1" 
         end if
         if tLabel > 24 and tLabel < 37 then
            put "H" into field "fld1" 
         end if
         
      else 
         -- if you have anything that should happen if 
         -- tLabel outside of 0 .... 36 then insert it here 
         -- or delete the else part
      end if
   end if
end mouseUp
regards
Bernd

topcat888
Posts: 44
Joined: Sat Jan 02, 2010 8:10 pm

Re: Clear Data Input Button..?

Post by topcat888 » Tue Jan 12, 2010 8:11 pm

It clears the lastNum perfectly, but doesn't enter the new number in place of the blank, only after the 'second' new number is entered does it start recording the lastNum's again plus the blank carries along the fields..?

Similarly, at the beginning when the first number is entered, the lastNum does not record anything until the second number is entered...

Also the put "L" into field "fld1" etc are not outputting now...

Thanks for your Patience (I am studying & understanding the process)...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Clear Data Input Button..?

Post by bn » Tue Jan 12, 2010 8:29 pm

topcat
Similarly, at the beginning when the first number is entered, the lastNum does not record anything until the second number is entered...
this should be taken care of now, please test and tell us how it goes

Code: Select all

on mouseup
   
   if the target contains "button" then
      put the label of the target into tLabel
      
      -- test for your range of interest
      -- between 0 and 36 and only then do the following
      if tLabel >-1 and tLabel < 37 then
         
         -- do your field shuffling before putting 
         -- the new value into "fld1" otherwise the new value would 
         -- be shifted to fld2 every time
         if not (field "fld1" = empty) then -- only shift when fld1 not empty
            put field "fld3" into field "fld4"
            put field "fld2" into field "fld3"
            put field "fld1" into field "fld2"
         end if
         
         -- now it is executed every time a button
         -- is clicked whose label is between 0 ... 36
         put field "lastNum17" into field "lastNum18"
         put field "lastNum16" into field "lastNum17"
         put field "lastNum15" into field "lastNum16"
         put field "lastNum14" into field "lastNum15"
         put field "lastNum13" into field "lastNum14"
         put field "lastNum12" into field "lastNum13"
         put field "lastNum11" into field "lastNum12"
         put field "lastNum10" into field "lastNum11"
         put field "lastNum9" into field "lastNum10"
         put field "lastNum8" into field "lastNum9"
         put field "lastNum7" into field "lastNum8"  
         put field "lastNum6" into field "lastNum7"
         put field "lastNum5" into field "lastNum6"
         put field "lastNum4" into field "lastNum5"  
         put field "lastNum3" into field "lastNum4"
         put field "lastNum2" into field "lastNum3"
         put field "lastNum1" into field "lastNum2"
         put tLabel into field "lastNum1" 
         
         
         if tLabel = 0 then 
            put "Z" into field "fld1"
         end if
         if tLabel > 0 and tLabel < 13 then 
            put "L" into field "fld1"
         end if
         if tLabel > 12 and tLabel < 25 then
            put "M" into field "fld1" 
         end if
         if tLabel > 24 and tLabel < 37 then
            put "H" into field "fld1" 
         end if
         
      else 
         -- if you have anything that should happen if 
         -- tLabel outside of 0 .... 36 then insert it here 
         -- or delete the else part
      end if
   end if
end mouseUp
regards
Bernd

topcat888
Posts: 44
Joined: Sat Jan 02, 2010 8:10 pm

Re: Clear Data Input Button..?

Post by topcat888 » Tue Jan 12, 2010 8:40 pm

All perfect except the blank (cleared) lastNum1 gets carried alone to lastNum2...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Clear Data Input Button..?

Post by bn » Tue Jan 12, 2010 8:48 pm

topcat,

try this:

Code: Select all

on mouseup
   
   if the target contains "button" then
      put the label of the target into tLabel
      
      -- test for your range of interest
      -- between 0 and 36 and only then do the following
      if tLabel >-1 and tLabel < 37 then
         
         -- do your field shuffling before putting 
         -- the new value into "fld1" otherwise the new value would 
         -- be shifted to fld2 every time
         if not (field "fld1" = empty) then -- only shift when fld1 not empty
            put field "fld3" into field "fld4"
            put field "fld2" into field "fld3"
            put field "fld1" into field "fld2"
         end if
         
         -- now it is executed only if field "lastNum1" is not empty
         -- so no carry over of empty lastNum1
         if not (field"lastNum1" is empty) then
            put field "lastNum17" into field "lastNum18"
            put field "lastNum16" into field "lastNum17"
            put field "lastNum15" into field "lastNum16"
            put field "lastNum14" into field "lastNum15"
            put field "lastNum13" into field "lastNum14"
            put field "lastNum12" into field "lastNum13"
            put field "lastNum11" into field "lastNum12"
            put field "lastNum10" into field "lastNum11"
            put field "lastNum9" into field "lastNum10"
            put field "lastNum8" into field "lastNum9"
            put field "lastNum7" into field "lastNum8"  
            put field "lastNum6" into field "lastNum7"
            put field "lastNum5" into field "lastNum6"
            put field "lastNum4" into field "lastNum5"  
            put field "lastNum3" into field "lastNum4"
            put field "lastNum2" into field "lastNum3"
            put field "lastNum1" into field "lastNum2"
         end if
         -- lastNum1 is always filled, either it overwrites
         -- the content of lastNum1 if it was shiftes
         -- or lastNum1 is filled if it was cleared
         put tLabel into field "lastNum1" 
         
         
         if tLabel = 0 then 
            put "Z" into field "fld1"
         end if
         if tLabel > 0 and tLabel < 13 then 
            put "L" into field "fld1"
         end if
         if tLabel > 12 and tLabel < 25 then
            put "M" into field "fld1" 
         end if
         if tLabel > 24 and tLabel < 37 then
            put "H" into field "fld1" 
         end if
         
      else 
         -- if you have anything that should happen if 
         -- tLabel outside of 0 .... 36 then insert it here 
         -- or delete the else part
      end if
   end if
end mouseUp
regards
Bernd

topcat888
Posts: 44
Joined: Sat Jan 02, 2010 8:10 pm

Re: Clear Data Input Button..?

Post by topcat888 » Tue Jan 12, 2010 9:02 pm

BINGO..! Thank you so much for your help Bernd...

I'm going to go away now and make sure I completely understand (and remember) the way you solved the problem...

:~)

Post Reply