Am I missing something
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Am I missing something
to give you an idea of what this is doing.
44 source fields with 1 character in each field. (SK fields)
I have 10 user entered fields (with values from 1-44 entered by the user). (PIK Fields)
44 final (we will call user swapped) fields (BK Fields)
When a user enters a string of 10 numbers into the PIK fields it will trigger what I thought was going to be a simple copy and paste string of events.
if the text of field PIK_1 = "2" then
select the text of field SK_2
copy
select the text of field swap2
paste
else
if the text of field PIK_1 = "3" then
select the text of field SK_3
copy
select the text of field swap2
paste
(ETC to PIK_44)
That part works.
My issue is getting the swap 1 and 2 to copy and paste from their areas Swap1 and swap2 to the BK fields.
here is that code. At the moment I have them triggered with buttons so that I can figure this out. I would really like it to ultimately be a part of the script so that its seamless.. say when the #10 field is exited. but at this point I am open to any suggestions.
here is that part of the script.
if the text of field PIK_1 = "1" then
select the text of field swap1
copy
select the text of field BK_1
paste
else
if the text of field PIK_1 = “2” then
select the text of field swap1
copy
select the text of field BK_2
paste
else
so on and so on to PIK_1 = 44
there may be a shorter way to do this since running 44 steps on each of the 10 fields may be overkill. but this is where I am at currently.
Any ideas.
44 source fields with 1 character in each field. (SK fields)
I have 10 user entered fields (with values from 1-44 entered by the user). (PIK Fields)
44 final (we will call user swapped) fields (BK Fields)
When a user enters a string of 10 numbers into the PIK fields it will trigger what I thought was going to be a simple copy and paste string of events.
if the text of field PIK_1 = "2" then
select the text of field SK_2
copy
select the text of field swap2
paste
else
if the text of field PIK_1 = "3" then
select the text of field SK_3
copy
select the text of field swap2
paste
(ETC to PIK_44)
That part works.
My issue is getting the swap 1 and 2 to copy and paste from their areas Swap1 and swap2 to the BK fields.
here is that code. At the moment I have them triggered with buttons so that I can figure this out. I would really like it to ultimately be a part of the script so that its seamless.. say when the #10 field is exited. but at this point I am open to any suggestions.
here is that part of the script.
if the text of field PIK_1 = "1" then
select the text of field swap1
copy
select the text of field BK_1
paste
else
if the text of field PIK_1 = “2” then
select the text of field swap1
copy
select the text of field BK_2
paste
else
so on and so on to PIK_1 = 44
there may be a shorter way to do this since running 44 steps on each of the 10 fields may be overkill. but this is where I am at currently.
Any ideas.
Re: Am I missing something
Hi Joseph,
hello and welcome to the forum!
Not sure I understand you completely, but maybe this is what you are looking for:
If that is not what you need, please explain where I was wrong.
Some helpful hints:
By using "lock/unlock screen", this is lightning fast and can be triggered anytime if neccessary, give it a try.
No need to copy/select/paste, simply "put"ting text INTO a field will overwrite its previous content, if any.
Get used to put Quotes around object names and everything that is a "string".
Best
Klaus
hello and welcome to the forum!
Not sure I understand you completely, but maybe this is what you are looking for:
Code: Select all
...
lock screen
repeat with i = 1 to 44
if the text of fld "PIK_1" = i then
put fld ("SK_" & i + 1) into fld "SWAP_2"
end if
end repeat
unlock screen
...
Some helpful hints:
By using "lock/unlock screen", this is lightning fast and can be triggered anytime if neccessary, give it a try.
No need to copy/select/paste, simply "put"ting text INTO a field will overwrite its previous content, if any.
Get used to put Quotes around object names and everything that is a "string".
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9647
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Am I missing something
Hi.
Welcome to the forum.
We will get through this.
In future, place all your handlers into the handler gadget ("</>")
There are several ways to shorten your handler, for example:
could be changed to:
but that is for later.
My problem is that I cannot test your handler snippets without actually building some or all of the fields. And there may be other issues, since the handlers you gave are not complete.
We will get through this. Write back with more information.
Craig Newman
Welcome to the forum.
We will get through this.
In future, place all your handlers into the handler gadget ("</>")
There are several ways to shorten your handler, for example:
Code: Select all
select the text of field SK_2
copy
select the text of field swap2
paste
Code: Select all
put field "SK_2" into field "swap2"
My problem is that I cannot test your handler snippets without actually building some or all of the fields. And there may be other issues, since the handlers you gave are not complete.
We will get through this. Write back with more information.
Craig Newman
Re: Am I missing something
Klaus wrote: ↑Wed Nov 07, 2018 5:08 pmHi Joseph,
hello and welcome to the forum!
Not sure I understand you completely, but maybe this is what you are looking for:If that is not what you need, please explain where I was wrong.Code: Select all
... lock screen repeat with i = 1 to 44 if the text of fld "PIK_1" = i then put fld ("SK_" & i + 1) into fld "SWAP_2" end if end repeat unlock screen ...
Some helpful hints:
By using "lock/unlock screen", this is lightning fast and can be triggered anytime if neccessary, give it a try.
No need to copy/select/paste, simply "put"ting text INTO a field will overwrite its previous content, if any.
Get used to put Quotes around object names and everything that is a "string".
Best
Klaus
Klaus
This worked!! loads of time saved copy and pasting.. I just changed the destination of from SK, to the BK is there way to put 2 variables into this? After its done with PIK_1, run the same on PIK_3
Code: Select all
lock screen
repeat with i = 1 to 44
if the text of fld "PIK_1" = i then
put fld swap2 into fld ("BK_" & i + 1)
end if
end repeat
unlock screen
I tried to add the variable under it like this
Code: Select all
lock screen
repeat with i = 1 to 44
if the text of fld "PIK_1" = i then
put fld swap2 into fld ("BK_" & i + 1)
end if
end repeat
repeat with i = 1 to 44
if the text of fld "PIK_3" = i then
put fld swap1 into fld ("BK_" & i + 1)
end if
end repeat
unlock screen
Thanks
Re: Am I missing something
Hi Joseph,
so the first loop actually works?
What exactly happend when "it stopped at PIK_1"?
Did you see an error? Or does this just not happen?
And do you really have a field named -> BK_45 ?
BTW:
You overwrite the same fields in both loops -> fld ("BK_" & i + 1)
Beest
Klaus
so the first loop actually works?
What exactly happend when "it stopped at PIK_1"?
Did you see an error? Or does this just not happen?
And do you really have a field named -> BK_45 ?
BTW:
You overwrite the same fields in both loops -> fld ("BK_" & i + 1)
Beest
Klaus
Re: Am I missing something
Ah, I overlooked:
Do like this:is there way to put 2 variables into this?
Code: Select all
...
lock screen
repeat with i = 1 to 44
if the text of fld "PIK_1" = i then
## QUOTES! 8)
put fld "swap2" into fld ("BK_" & i + 1)
end if
## Why start another loop? :-)
if the text of fld "PIK_3" = i then
put fld "swap1" AFTER fld ("BK_" & i + 1)
## Add space
## OR: put " " & fld "swap1" AFTER fld ...
## Or put variable at the beginning of field
## OR: ... BEFORE fld ...
## Add a new line
## OR: ... CR & fld "swap1" AFTER fld ...
## You get the picture :)
end if
end repeat
unlock screen
...
Re: Am I missing something
no fields PIK 1 and 3 are the 2 that I want to be linked really in this script..
when I ran the script that I posted with both it just ran the PIK_1 area but just nothing on the PIK_3
ideally it should replace the contents of corresponding user entered numbers on PIK 1 and 3
say they enter 33 into PIK_1 and 19 into PIK_3
it should replace the contents of BK_1 with field contents swap2 and BK_3 with swap1
when I ran the script that I posted with both it just ran the PIK_1 area but just nothing on the PIK_3
ideally it should replace the contents of corresponding user entered numbers on PIK 1 and 3
say they enter 33 into PIK_1 and 19 into PIK_3
it should replace the contents of BK_1 with field contents swap2 and BK_3 with swap1
Re: Am I missing something
I just used your example script, since I have no idea what you really want.
Re: Am I missing something
And what does "when I ran the script that I posted with both it just ran the PIK_1 area but just nothing on the PIK_3" mean? See my previous but one posting with all these questions.