How would you do this?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How would you do this?
The problem.
I have a group of fields with the address of Fld "Field " & N N being an integer from 1 to 100
The fields fill up from number 1
I need to insert data rather than overwrite, so the fields further down the list (higher numbers) need to be moved down 1 field each to create a space for the inserted data.
If 100 fields already have data, then 100 can be overwritten so 99 becomes 100...
The question.
What slick code can detect the first empty field, or 100 if all full, and then move all the fields from the insertion point, down one place (into the higher number). ??
Any ideas?
I have a group of fields with the address of Fld "Field " & N N being an integer from 1 to 100
The fields fill up from number 1
I need to insert data rather than overwrite, so the fields further down the list (higher numbers) need to be moved down 1 field each to create a space for the inserted data.
If 100 fields already have data, then 100 can be overwritten so 99 becomes 100...
The question.
What slick code can detect the first empty field, or 100 if all full, and then move all the fields from the insertion point, down one place (into the higher number). ??
Any ideas?
Re: How would you do this?
Sorry, no idea what you want to do...
Re: How would you do this?
Thanks Klaus,
fld 1 full (zxc)
fld 2 full ( asd) <-- insert Field "Data" between 2 and 3
fld 3 full (ert)
fld 4 full (dfg)
Becomes
fld 1 full (zxc)
fld 2 full ( asd)
Fld 3 contains the inserted data <-- insert Field "Data" between 2 and 3
fld 4 full (ert)
fld 5 full (dfg)
Does this clarify?
fld 1 full (zxc)
fld 2 full ( asd) <-- insert Field "Data" between 2 and 3
fld 3 full (ert)
fld 4 full (dfg)
Becomes
fld 1 full (zxc)
fld 2 full ( asd)
Fld 3 contains the inserted data <-- insert Field "Data" between 2 and 3
fld 4 full (ert)
fld 5 full (dfg)
Does this clarify?
Re: How would you do this?
Still not too clear...
Do you need to really CREATE a new field and postion this new field between the existing fields?
Or do you already have all neccessary fields and "just" want to "move" the content?
Can't you use a datagrid or listfield for that?
Managing lots of fields like this meand lots of work and calculations.
Do you need to really CREATE a new field and postion this new field between the existing fields?
Or do you already have all neccessary fields and "just" want to "move" the content?
Can't you use a datagrid or listfield for that?
Managing lots of fields like this meand lots of work and calculations.
Re: How would you do this?
I think I understand what he is trying to do, maybe.
100 fields, maybe empty, maybe not. If empty, put data into it, if no field is empty, move the contents of field 1 -> field 2, fld 2 -> 3, etc.
If that is the case, your going to need at least one repeat loop, and possibly 2. Psuedo code (not tested) -
if tmpNotEmpty = 100, then all your fields have text.
You can use similar code to move the code from the last field to the first, starting your repeat loop with the 100th field and working backwards.
100 fields, maybe empty, maybe not. If empty, put data into it, if no field is empty, move the contents of field 1 -> field 2, fld 2 -> 3, etc.
If that is the case, your going to need at least one repeat loop, and possibly 2. Psuedo code (not tested) -
Code: Select all
repeat with x = 1 to the number of fields
#assumes your data is in a variable...
// checks if field is empty, inserts data if empty
if field x is "" then
put myData into field x
else // no field was empty...
add 1 to tmpNotEmpty
end if
end repeat
You can use similar code to move the code from the last field to the first, starting your repeat loop with the 100th field and working backwards.
Re: How would you do this?
This is my home brew solution.
Thank you everyone for your suggestions.
Thank you everyone for your suggestions.
Code: Select all
--*** Check if this field has data in it. if so, move data below it down one and save.
repeat with tCounter = 99 down to ComtLoc
if fld ("Field " & tCounter )on card id 1169 = empty then
else
put fld( "Field " & tCounter) on card id 1169 into fld( "Field " & tCounter +1) on card id 1169
end if
end repeat
put fld "Comment" into Fld ("Field " & ComtLoc) on card id 1169