partly upset down
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
partly upset down
Hallo,
my problem:
I have some lines with only one number. If the the following number of the line = (+1) I would like to get this group in reverse order as word 2 of that line - so it should look like this:
1
5
27 - 29
28 - 28
29 - 27
45
50
291 - 294
292 - 293
293 - 292
294 - 291
Who knows the trick?
Kind regards,
chrisw
my problem:
I have some lines with only one number. If the the following number of the line = (+1) I would like to get this group in reverse order as word 2 of that line - so it should look like this:
1
5
27 - 29
28 - 28
29 - 27
45
50
291 - 294
292 - 293
293 - 292
294 - 291
Who knows the trick?
Kind regards,
chrisw
Re: partly upset down
Hi,
Does this help?
And are you able to create a "repeat with" loop that does something like this (pseudocode)?
In other words, you loop through all the lines in your list, and if a particular line has a length of one, and the length of the following line is three, then switch the following line.
Write back with what you came up with. I assume your data is exactly as you describe, or additional work will be required to parse it correctly.
Craig Newman
Does this help?
Code: Select all
put word 3 of yourLine & " - " & word 1 of yourLine into yourLine
Code: Select all
if the length of line tLine of yourList = 1 and the length of line (tLine + 1) = 3 then doTheSwitchAsPerTheAboveInTheFollowingLine
Write back with what you came up with. I assume your data is exactly as you describe, or additional work will be required to parse it correctly.
Craig Newman
Re: partly upset down
Hallo, Craig,
I gave You a shortcut of the list.
It is a list from 1 to 100 or more (or less).
Every time, following lines contain a special word, I need them to appear in reverse order, e.g. if that word is in line 3 to 5 they should appear in line 5 down to 3 (5 = 3; 4 = 4; 3 = 5).
If that word appears in a single line, there is no need to change the order, e.g. if that word is in line 7 and not in line 6 or 8 it should appear in line 7.
The problem for me is: how to get and reverse those groups (they may extend from 2 to 10 lines, once or oftener. That is the pattern, the form.)
Hoping, You now better understand, what is my problem (my english is not the best), with kind regards,
Christoph
I gave You a shortcut of the list.
It is a list from 1 to 100 or more (or less).
Every time, following lines contain a special word, I need them to appear in reverse order, e.g. if that word is in line 3 to 5 they should appear in line 5 down to 3 (5 = 3; 4 = 4; 3 = 5).
If that word appears in a single line, there is no need to change the order, e.g. if that word is in line 7 and not in line 6 or 8 it should appear in line 7.
The problem for me is: how to get and reverse those groups (they may extend from 2 to 10 lines, once or oftener. That is the pattern, the form.)
Hoping, You now better understand, what is my problem (my english is not the best), with kind regards,
Christoph
Re: partly upset down
Hmmm.
Please give a short example of your list, and another example of the output you want. Something like this:
It is simple to reverse the order of certain lines:
1
2
3
4
5
gives:
1
2
5
4
3
LC can detect any condition within a line, and be able to examine and manipulate the text in any of the following lines that you want. I am still not understanding the problem. I just do not yet grasp those conditions. Why, in the above example, does the "2" trigger the reversal in some of the following lines? How many lines should be reversed? That sort of thing.
Craig
Please give a short example of your list, and another example of the output you want. Something like this:
It is simple to reverse the order of certain lines:
1
2
3
4
5
gives:
1
2
5
4
3
LC can detect any condition within a line, and be able to examine and manipulate the text in any of the following lines that you want. I am still not understanding the problem. I just do not yet grasp those conditions. Why, in the above example, does the "2" trigger the reversal in some of the following lines? How many lines should be reversed? That sort of thing.
Craig
Re: partly upset down
I'm not sure I understand correctly, but I think you are looking for something like this??
I'm sure there are many more elegant ways to do the job, assuming this is what you want to achieve
Code: Select all
on mouseUp
put field "Field1" into tList
put cr & "null_stuff" after tList --quick and dirty method of ensuring the loop completes processing the last line/batch
put 0 into tStart
put word 1 of line 1 of tList into tLimit
repeat for each line tLine in tList
put word 1 of tLine into tItem
if tItem is tLimit + 1 then
put tItem into tLimit
else
if tStart is tLimit then
put tStart & cr after tNewLines
else
if tStart is 0 then
put tItem into tStart
else
put 0 into tDeduct
repeat with i = tStart to tLimit
put i & " - " & (tLimit - tDeduct) & cr after tNewLines --use whatever separator you wish, rather than " - "
add 1 to tDeduct --quick and dirty method of reversing the order of the second "word" of the line
end repeat
end if
end if
put tItem into tStart
put tItem into tLimit
end if
end repeat
filter tNewLines without empty
put tNewLines into field "Field2"
end mouseUp
Re: partly upset down
Does this do what you need?
Code: Select all
function doSort pData
set the itemdel to "-"
sort pData numeric descending by item 2 of each
sort pData numeric by item 1 of each
return pData
end doSort
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: partly upset down
If I understand rightly, the OP has a list that looks like:
1
2
3
6
8
10
11
12
and wants the result to be
1 - 3
2 - 2
3 - 1
6
8
10 - 12
11 - 11
12 - 10
where lines which have consecutive numbers have that range reversed as the (new) second word value.
There isn't (from what I understand) a second word value on any line of the original list.
1
2
3
6
8
10
11
12
and wants the result to be
1 - 3
2 - 2
3 - 1
6
8
10 - 12
11 - 11
12 - 10
where lines which have consecutive numbers have that range reversed as the (new) second word value.
There isn't (from what I understand) a second word value on any line of the original list.
Re: partly upset down
@SparkOut, I see. My suggestion won't work of course if lines don't have a second item. You're probably right. I'm not quite sure what the original data is, and what the final result should be.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: partly upset down
Thanks to all! But it did not help!
the original is:
1,shalom
2,shalom
3, geneva
4, geneva
5,shalom
6,shalom
7,shalom
8, geneva
....
it should show up:
1,shalom,2
2,shalom,1
3,geneva
4, geneva
5,shalom,7
6,shalom,6
7,shalom,5
8, geneva
an so on.
chrisw
the original is:
1,shalom
2,shalom
3, geneva
4, geneva
5,shalom
6,shalom
7,shalom
8, geneva
....
it should show up:
1,shalom,2
2,shalom,1
3,geneva
4, geneva
5,shalom,7
6,shalom,6
7,shalom,5
8, geneva
an so on.
chrisw
Re: partly upset down
Anyone getting closer to this? I had asked what conditions triggered the data manipulation. I still do not get why, for example, "shalom" needs it but "geneva" does not.
ChrisW. Do you see what I mean?
The actual mechanics of doing this is trivial. But where in the list should this procedure be applied? What distinguishes the list items?
Craig
ChrisW. Do you see what I mean?
The actual mechanics of doing this is trivial. But where in the list should this procedure be applied? What distinguishes the list items?
Craig
Re: partly upset down
..........
Last edited by [-hh] on Wed Aug 13, 2014 3:38 pm, edited 1 time in total.
shiftLock happens
Re: partly upset down
What Hermann said. As usual.
ChrisW. Is that it? You set aside a particular word in that list that you wanted to flag? If so, that answers my question, namely, "how do it know?"
Craig
ChrisW. Is that it? You set aside a particular word in that list that you wanted to flag? If so, that answers my question, namely, "how do it know?"
Craig
Re: partly upset down
Hallo,
You were great. What Hermann wrote, really works excellent!
Thank You cery much!
Shalom and Geneva are font names, and the reversed order I need, to transmit text from font Shalom to Unicode.
Kind regards,
Christoph
You were great. What Hermann wrote, really works excellent!
Thank You cery much!
Shalom and Geneva are font names, and the reversed order I need, to transmit text from font Shalom to Unicode.
Kind regards,
Christoph