I am seeking a pointer or a little guidance on the code for updating a text field that has footnotes as numbered links. For example:
Using read from file, the field is populated by an external text file, the footnotes text having been tagged with html. I want a user to be able to edit this example by adding a new statement supported by a footnote, such as writing a sentence between the first and second sentence. Thus, in the example, the footnote number of the new sentence would become FN2, and the footnote for the last sentence would become FN3.Hitchhiker's Guide to the Universe was written by Douglas Adams.FN1 Towel Day is celebrated on May 25 in Innsbruck, Austria.FN2
I am not a trained programmer, so that only method I can think is the following. The user types the second sentence, adds the following marked footnote text after its period, and presses a button. <Born 1952; Died in 2001> Thus:Hitchhiker's Guide to the Universe was written by Douglas Adams.FN1 He was born in England and died in California.FN2 Towel Day is celebrated on May 25 in Innsbruck, Austria.FN3
Here is just the beginning of the procedure. The function seems to get the correct footnote number, but after many experiments I still cannot figure out the code to insert "FN2" after "California." in the text file "Adams.txt":Hitchhiker's Guide to the Universe was written by Douglas Adams.FN1 He was born in England and died in California.<Born 1952; Died 2001.> Towel Day is celebrated on May 25 in Innsbruck, Austria.FN2
Code: Select all
put offset("<", fld("text")) into tCharPos1
put offset(">", fld("text")) into tCharPos2
--get the footnote
put char tCharPos1 to tCharPos2 of fld "text" into tFootnote
--get the text preceding the footnote
put char 1 to (tCharPos1-1) of fld "text" into tFieldText
--query: now, how should tFieldText be parsed so that the code below will capture the
same text in the file "Adams.txt"?
open file "Adams.txt" for update
read from file "Adams.txt" until ? | for ?
## If the variable "it" contains the the text preceding the footnote,
## this code seems to work:
put NumOccurrInText("<a>", it) into tNumOccurr
Add 1 to tNumOccurr
write "<a>FN"&tNumOccurr&"</a>" to file "Adams.txt" at ? | start ?
close "Adams.txt"
function NumOccurrInText pSearch, pCont
put 0 into rNumOccurrInText
put 0 into tCharsToSkip
repeat
put offset(pSearch, pCont, tCharsToSkip) into OneOccurr
if OneOccurr = 0 then exit repeat
add OneOccurr to tCharsToSkip
add 1 to rNumOccurrInText
end repeat
return rNumOccurrInText
end NumOccurrInText
Monty May