Delete line, row, record ?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Delete line, row, record ?
I have in an array sets of numbers like "2,34,5,23" etc
and want to delete any set of numbers if a number
(say 34) appears again in another series of numbers.
I can put them into a field so could delete a "row" there
or else delete the "record" from the array perhaps.
I also want to "pack" the array or field after a delete
i.e remove blank "records".
Can't find anything to do either of these although no doubt it
can be done. Just need a push in the right direction.
and want to delete any set of numbers if a number
(say 34) appears again in another series of numbers.
I can put them into a field so could delete a "row" there
or else delete the "record" from the array perhaps.
I also want to "pack" the array or field after a delete
i.e remove blank "records".
Can't find anything to do either of these although no doubt it
can be done. Just need a push in the right direction.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
Hi.
Several ways to do what you want. Read about the "delete variable" command, which can delete a specific key in an array variable. You may also want to look at the "lineOffset" function, which would allow you to locate a string in a line in an ordinary variable, and delete it. That would work in a field as well, or any container.
As for packing a variable, you can always:
or
That sort of thing.
Craig Newman
Several ways to do what you want. Read about the "delete variable" command, which can delete a specific key in an array variable. You may also want to look at the "lineOffset" function, which would allow you to locate a string in a line in an ordinary variable, and delete it. That would work in a field as well, or any container.
As for packing a variable, you can always:
Code: Select all
repeat for each line tLine in yourVariable
if tLine <> "" then put tLIne & return after accum
end repeat
answer accum
Code: Select all
repeat with y = the number of lines of yourVariable down to 1
if line y of yourVariable = "" then delete line y of yourVariable
end repeat
answer yourVariable
Craig Newman
Re: Delete line, row, record ?
Craig
Spot on!
I see that your location is New York so if I say "I wish I was clever like you Brian"
it won't mean anything but if you were in England in the '70's you'd remember
the Cadbury's television advertisement in which the six-year-old boy explained
to his younger brother how they put the nuts in the chocolate.
Thank you!
Spot on!
I see that your location is New York so if I say "I wish I was clever like you Brian"
it won't mean anything but if you were in England in the '70's you'd remember
the Cadbury's television advertisement in which the six-year-old boy explained
to his younger brother how they put the nuts in the chocolate.
Thank you!
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
I'm trying to use code from the Dictionary to step through an
array...
repeat for each line tKey in the keys of theArray
but in the debugger I see that it jumps over of the repeat loop.
Possible reasons anyone?
array...
repeat for each line tKey in the keys of theArray
but in the debugger I see that it jumps over of the repeat loop.
Possible reasons anyone?
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
There are no "lines" that can be enumerated in an array. That is what takes a little getting used to. An array variable is not an ordinary variable, where chunk expressions may be applied. The fact that the debugger deconstructs an array variable into visible form WHILE STEPPING THROUGH is just a benefice.
What you wanted was
Now step through...
Craig
What you wanted was
Code: Select all
repeat for each key tKey in theArray
Craig
Re: Delete line, row, record ?
Well, the dictionary entry under "keys" says
repeat for each line....
So perhaps this should be corrected?
repeat for each line....
So perhaps this should be corrected?
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
No, no.
I mistook something, likely due to either overwork or sloppiness.
If you bring out "the keys", you indeed have an ordinary list, chunk accessible. What was the code that would not cycle through the lines of the keys?
Craig
I mistook something, likely due to either overwork or sloppiness.
If you bring out "the keys", you indeed have an ordinary list, chunk accessible. What was the code that would not cycle through the lines of the keys?
Craig
Re: Delete line, row, record ?
So far I have the following:
repeat for each key tKey in theArray
if aVar is among the items of theArray[tKey] then
put tKey & CR after field fldArrayDisplay
put char 1 of tKey & CR after field fldArrayDisplay
---works so far---
put char 1 of tKey into sVar
--delete variable theArray[char 1 of tKey] --arrayIndex[char 1 of tKey]
--delete variable theArray[sVar]
--delete theArray[sVar]
end if
end repeat
Surprised to find that the key has the form "4,1" rather than "4".
Also surprised (for a moment) that they're listed "bottom up" but
then remembered that when one "line" is deleted the remaining
move up to fill the "gap".
You'll see from the code above that I haven't yet found the right
code to "delete variable".
Any ideas?
Note: After achieving the successful finding of the keys I went out
and bought myself a cigar.
repeat for each key tKey in theArray
if aVar is among the items of theArray[tKey] then
put tKey & CR after field fldArrayDisplay
put char 1 of tKey & CR after field fldArrayDisplay
---works so far---
put char 1 of tKey into sVar
--delete variable theArray[char 1 of tKey] --arrayIndex[char 1 of tKey]
--delete variable theArray[sVar]
--delete theArray[sVar]
end if
end repeat
Surprised to find that the key has the form "4,1" rather than "4".
Also surprised (for a moment) that they're listed "bottom up" but
then remembered that when one "line" is deleted the remaining
move up to fill the "gap".
You'll see from the code above that I haven't yet found the right
code to "delete variable".
Any ideas?
Note: After achieving the successful finding of the keys I went out
and bought myself a cigar.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
The answer to the above question is
delete variable theArray[tKey]
Worth another cigar don't you think?
delete variable theArray[tKey]
Worth another cigar don't you think?
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
Now I'm trying to figure out how to add variable (record ?)
to the array.
Could anyone remind me how I can post this stack into
the "Resources" section so that everyone can have a go
at answering this question.
I'm out of cigars so no prize for the correct answer.
to the array.
Could anyone remind me how I can post this stack into
the "Resources" section so that everyone can have a go
at answering this question.
I'm out of cigars so no prize for the correct answer.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
That smoke has gone to your head, at least for the first part of your query:
Craig
Code: Select all
on mouseUp
repeat with y = 1 to 10
put y * 10 into tenTimes[y]
end repeat
put 150 into tenTimes[15} -- new "record"
end mouseUp
Re: Delete line, row, record ?
My current favorite way to delete blank lines is a one-liner:dunbarx wrote:As for packing a variable, you can always:
Code: Select all
filter tVar without empty
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Delete line, row, record ?
Craig
In the code you give you know that theArray[15] has nothing
in it. In my case I don't know so have to ascertain the next
index number.
In the code you give you know that theArray[15] has nothing
in it. In my case I don't know so have to ascertain the next
index number.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
I've put my test stack in Sample Stack with the name
"Array Manipulation".
A curiousity: seems that LC accesses arrays in a rather odd
DOS way i.e. in DOS if you highlight ten file to delete it will first
delete file 1 then file 10, file 9 etc. down to file 2.
Also note that deleted variables don't leave a blank line and
the remaining entries in the array keep their original index numbers
so the number of variables in the array can't be used to ascertain
the next index for adding a new variable.
Of course any of the above points might be the result of inept programming.
"Array Manipulation".
A curiousity: seems that LC accesses arrays in a rather odd
DOS way i.e. in DOS if you highlight ten file to delete it will first
delete file 1 then file 10, file 9 etc. down to file 2.
Also note that deleted variables don't leave a blank line and
the remaining entries in the array keep their original index numbers
so the number of variables in the array can't be used to ascertain
the next index for adding a new variable.
Of course any of the above points might be the result of inept programming.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Delete line, row, record ?
The search is over.
To add a variable to theArray...
repeat with x = 1 to 100
if theArray[x] = "" then
put "7,6,5,4,3,2,1" into theArray[x]
exit repeat
end if
end repeat
To add a variable to theArray...
repeat with x = 1 to 100
if theArray[x] = "" then
put "7,6,5,4,3,2,1" into theArray[x]
exit repeat
end if
end repeat
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.