| Line-No. / Ref. | Code Line |
| 0001 | Public Function Notes_Text_Format(NoteID, Note_Ref, strLine, Last_Changed_Timestamp As Long, Notes_Group_Name, Optional strPrintable) |
| 0002 | Dim x As Long |
| 0003 | Dim Y As Long |
| 0004 | Dim z As Long |
| 0005 | Dim xx As String |
| 0006 | Dim iSuperscript As Integer |
| 0007 | Dim iSection As Integer |
| 0008 | Dim strControlQuery As String |
| 0009 | Dim rsNoteType As Recordset |
| 0010 | Dim rsSecure As Recordset |
| 0011 | Dim rsLatestTimestamp As Recordset |
| 0012 | Dim rsNoteID As Recordset |
| 0013 | Dim rsFNCheck As Recordset |
| 0014 | Dim strLink1 As String |
| 0015 | Dim strLink2 As String |
| 0016 | Dim iFootNoteID As Integer |
| 0017 | Dim i As Long |
| 0018 | Dim TheWord As String |
| 0019 | Dim FootNoteTimestamp As Long |
| 0020 | Dim strDirectory As String |
| 0021 | Dim strPrintThisSuperscript As String |
| 0022 | Dim No_FN As String |
| 0023 | Dim FN_Start As Long |
| 0024 | Dim FN_End As Long |
| 0025 | Dim strQuery As String |
| 0026 | Dim rst As Recordset |
| 0027 | Dim rst2 As Recordset |
| 0028 | Dim db As Database |
| 0029 | Dim FN_Number_Used As String |
| 0030 | Dim DudRef As String |
| 0031 | Dim Ref_Type As String |
| 0032 | Dim strRef As String |
| 0033 | Dim iSuperscript_Display As Integer |
| 0034 | Dim Footnote_Text As String |
| 0035 | Dim sw As StopWatch |
| 0036 | Dim sw2 As StopWatch |
| 0037 | 'Test_Flag = True |
| 0038 | If Test_Flag = True Then |
| 0039 | Set sw = New StopWatch |
| 0040 | Set sw2 = New StopWatch |
| 0041 | sw.StartTimer |
| 0042 | End If |
| 0043 | If Test_Flag = True Then |
| 0044 | sw2.StartTimer |
| 0045 | End If |
| 0046 | If IsMissing(strPrintable) Then |
| 0047 | Cross_Reference_Table_Open = False |
| 0048 | Set rsCross_Reference_Table = Nothing |
| 0049 | OK = Zap_Cross_References("N", NoteID, Last_Changed_Timestamp) |
| 0050 | Ref_Type = "N" |
| 0051 | Else |
| 0052 | Ref_Type = "X" |
| 0053 | End If |
| 0054 | If Test_Flag = True Then |
| 0055 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Startup" |
| 0056 | sw2.StartTimer |
| 0057 | End If |
| 0058 | 'Delete items from the In-sheet Footnotes table |
| 0059 | Set db = CurrentDb |
| 0060 | strQuery = "Delete * From Note_Footnotes Where Note_Footnotes!Note_ID = " & NoteID & ";" |
| 0061 | DoCmd.RunSQL (strQuery) |
| 0062 | 'Now get ready to insert rows to In-sheet Footnotes table |
| 0063 | strQuery = "Select * From Note_Footnotes Where Note_Footnotes!Note_ID = " & NoteID & ";" |
| 0064 | Set rst = db.OpenRecordset(strQuery) |
| 0065 | strLine = ReplaceCode(strLine, Chr(13) & Chr(10), " ") |
| 0066 | strLine = Remove_Dummy_Ref(strLine) |
| 0067 | 'Added 25/03/20: For "Aeon Comment" links to Abstract in Summary Task Lists ... hopefully it won't muck up other Notes! |
| 0068 | If Not IsMissing(strPrintable) Then |
| 0069 | strLine = Replace(strLine, """../../", """../../../") |
| 0070 | End If |
| 0071 | 'Create the notes links |
| 0072 | x = 1 |
| 0073 | iSuperscript = 1 |
| 0074 | 'Process In-sheet Footnotes |
| 0075 | x = InStr(x, strLine, "++FN") |
| 0076 | If x > 0 Then |
| 0077 | x = 1 |
| 0078 | No_FN = "No" |
| 0079 | x = InStr(x, strLine, "++") |
| 0080 | Do Until (No_FN = "Yes" And x = 0) |
| 0081 | If x > 0 Then |
| 0082 | If Mid(strLine, x + 2, 2) = "FN" Then |
| 0083 | 'In-page footnote |
| 0084 | FN_Start = x |
| 0085 | x = x + 1 |
| 0086 | x = InStr(x, strLine, "++") |
| 0087 | If x > 0 Then |
| 0088 | FN_End = x + 1 |
| 0089 | Footnote_Text = Mid(strLine, FN_Start + 4, FN_End - FN_Start - 5) & "" |
| 0090 | If Footnote_Text <> "" Then |
| 0091 | If Mid(strLine, FN_Start - 1, 1) = " " Then |
| 0092 | i = FindWord(strLine, FN_Start - 1, "]") |
| 0093 | Else |
| 0094 | i = FindWord(strLine, FN_Start, "]") |
| 0095 | End If |
| 0096 | 'Add to table |
| 0097 | rst.AddNew |
| 0098 | rst.Fields(0) = NoteID |
| 0099 | rst.Fields(1) = iSuperscript |
| 0100 | rst.Fields(2) = Footnote_Text |
| 0101 | rst.Fields(3) = Now() |
| 0102 | rst.Update |
| 0103 | 'Find if a duplicate FN |
| 0104 | Mark_Duplicate_Footnotes (NoteID) |
| 0105 | Set rsFNCheck = CurrentDb.OpenRecordset("SELECT Note_Footnotes.Note_ID, Note_Footnotes.FN_ID, Note_Footnotes.Master_ID FROM Note_Footnotes WHERE (((Note_Footnotes.Note_ID)=" & NoteID & ") AND ((Note_Footnotes.FN_ID)=" & iSuperscript & "));") |
| 0106 | rsFNCheck.MoveFirst |
| 0107 | If rsFNCheck.Fields(1) <> rsFNCheck.Fields(2) Then |
| 0108 | iSuperscript_Display = rsFNCheck.Fields(2) |
| 0109 | Else |
| 0110 | iSuperscript_Display = iSuperscript |
| 0111 | End If |
| 0112 | Set rsFNCheck = Nothing |
| 0113 | strLink1 = "" |
| 0114 | 'strLink2 = "" & iSuperscript & IIf(iSuperscript <> iSuperscript_Display, "=" & iSuperscript_Display, "") & "" & "" |
| 0115 | 'The above looks uply, without being super-helpful, so was removed on 01/04/2021 |
| 0116 | strLink2 = "" & iSuperscript & "" & "" |
| 0117 | If Mid(strLine, FN_Start - 1, 1) = " " Then |
| 0118 | TheWord = Mid(strLine, i, FN_Start - 1 - i) |
| 0119 | Else |
| 0120 | TheWord = Mid(strLine, i, FN_Start - i) |
| 0121 | End If |
| 0122 | If Right(TheWord, 1) = "]" Then |
| 0123 | TheWord = Mid(TheWord, 2, Len(TheWord) - 2) |
| 0124 | End If |
| 0125 | xx = Left(strLine, i - 1) & strLink1 & TheWord & strLink2 |
| 0126 | x = Len(xx) |
| 0127 | strLine = xx & Mid(strLine, FN_End + 1) |
| 0128 | iSuperscript = iSuperscript + 1 |
| 0129 | End If |
| 0130 | x = x + 1 |
| 0131 | x = InStr(x, strLine, "++") |
| 0132 | End If |
| 0133 | Else |
| 0134 | No_FN = "Yes" |
| 0135 | 'Ignore Note-links (ie. links to other Notes) |
| 0136 | x = x + 1 |
| 0137 | x = InStr(x, strLine, "++") |
| 0138 | If x > 0 Then |
| 0139 | x = x + 2 |
| 0140 | x = InStr(x, strLine, "++") |
| 0141 | iSuperscript = iSuperscript + 1 |
| 0142 | End If |
| 0143 | End If |
| 0144 | Else |
| 0145 | No_FN = "Yes" |
| 0146 | End If |
| 0147 | Loop |
| 0148 | End If |
| 0149 | iSuperscript = 1 |
| 0150 | x = 1 |
| 0151 | x = InStr(x, strLine, "++") |
| 0152 | z = 1 |
| 0153 | iSection = 0 |
| 0154 | If x > 0 Then |
| 0155 | z = InStr(x, strLine, " ") |
| 0156 | End If |
| 0157 | If Test_Flag = True Then |
| 0158 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Note Links Created" |
| 0159 | sw2.StartTimer |
| 0160 | End If |
| 0161 | 'Encode WebRefs now lest "+"'s confuse later processing |
| 0162 | strLine = WebEncode(strLine) |
| 0163 | Do While x > 0 |
| 0164 | 'Skip over superscripts used by internal footnotes |
| 0165 | FN_Number_Used = "Yes" |
| 0166 | Do While FN_Number_Used = "Yes" |
| 0167 | strQuery = "Select * From Note_Footnotes Where Note_Footnotes!Note_ID = " & NoteID & " AND Note_Footnotes!FN_ID = " & iSuperscript & ";" |
| 0168 | Set rst2 = db.OpenRecordset(strQuery) |
| 0169 | If Not rst2.EOF Then |
| 0170 | iSuperscript = iSuperscript + 1 |
| 0171 | Else |
| 0172 | FN_Number_Used = "No" |
| 0173 | End If |
| 0174 | Set rst2 = Nothing |
| 0175 | Loop |
| 0176 | If x > 1 Then |
| 0177 | If Mid(strLine, x - 1, 1) = " " Then |
| 0178 | i = FindWord(strLine, x - 1, "]") |
| 0179 | TheWord = Mid(strLine, i, x - 1 - i) |
| 0180 | Else |
| 0181 | i = FindWord(strLine, x, "]") |
| 0182 | TheWord = Mid(strLine, i, x - i) |
| 0183 | End If |
| 0184 | Else |
| 0185 | i = FindWord(strLine, x, "]") |
| 0186 | End If |
| 0187 | strPrintThisSuperscript = "Yes" |
| 0188 | DudRef = "No" |
| 0189 | strRef = "" |
| 0190 | Y = InStr(x + 1, strLine, "++") |
| 0191 | If Y = 0 Then |
| 0192 | x = 0 |
| 0193 | DudRef = "Yes" |
| 0194 | Else |
| 0195 | If Y > x + 30 Then |
| 0196 | x = Y - 1 |
| 0197 | DudRef = "Yes" |
| 0198 | Else |
| 0199 | If Y = x + 1 Then |
| 0200 | 'Check this is the "++++" case where we have to look up the reference |
| 0201 | If Mid(strLine, x, 4) = "++++" Then |
| 0202 | 'Find the key-word(s) |
| 0203 | If Right(TheWord, 1) = "]" Then |
| 0204 | TheWord = Mid(TheWord, 2, Len(TheWord) - 2) |
| 0205 | End If |
| 0206 | 'Find the Note ID. NB uses the Note_Alternates table! |
| 0207 | Set rsNoteID = CurrentDb.OpenRecordset("SELECT Notes.ID FROM Note_Alternates INNER JOIN Notes ON Note_Alternates.Item_Title = Notes.Item_Title WHERE (((Note_Alternates.Item_Alt_Title)=""" & TheWord & """));") |
| 0208 | If rsNoteID.EOF Then |
| 0209 | strRef = "1256" 'The "dud links" Note! |
| 0210 | Else |
| 0211 | rsNoteID.MoveFirst |
| 0212 | strRef = rsNoteID.Fields(0) |
| 0213 | End If |
| 0214 | Set rsNoteID = Nothing |
| 0215 | strLine = Left(strLine, x + 1) & strRef & Mid(strLine, x + 2) |
| 0216 | Y = Y + 1 + Len(strRef) |
| 0217 | End If |
| 0218 | Else |
| 0219 | strRef = Mid(strLine, x + 2, Y - x - 2) |
| 0220 | End If |
| 0221 | If Left(strRef, 2) = "NP" Then |
| 0222 | strRef = Mid(strRef, 3, Len(strRef)) |
| 0223 | strPrintThisSuperscript = "No" |
| 0224 | End If |
| 0225 | If Len(strRef) > 0 Then |
| 0226 | If InStr(strRef, "#") > 0 Then |
| 0227 | If IsNumeric(Left(strRef, InStr(strRef, "#") - 1)) Then |
| 0228 | iFootNoteID = Left(strRef, InStr(strRef, "#") - 1) |
| 0229 | strRef = Mid(strRef, InStr(strRef, "#"), Len(strRef)) |
| 0230 | strRef = Replace(strRef, "#", "#Off-Page_Link_") |
| 0231 | Else |
| 0232 | x = Y - 1 |
| 0233 | DudRef = "Yes" |
| 0234 | End If |
| 0235 | Else |
| 0236 | If IsNumeric(strRef) Then |
| 0237 | iFootNoteID = strRef |
| 0238 | strRef = "" |
| 0239 | Else |
| 0240 | x = Y - 1 |
| 0241 | DudRef = "Yes" |
| 0242 | End If |
| 0243 | End If |
| 0244 | End If |
| 0245 | End If |
| 0246 | End If |
| 0247 | If DudRef = "No" Then |
| 0248 | 'Find whether to Print the superscript (if not already decided not to print) |
| 0249 | If strPrintThisSuperscript = "Yes" Then |
| 0250 | If (Not IsMissing(strPrintable)) And (Val(Note_Ref) <> 0) Then |
| 0251 | 'Just use this recordset for convenience |
| 0252 | Set rsSecure = CurrentDb.OpenRecordset("SELECT Note_Usage_Temp.Note_From FROM Note_Usage_Temp WHERE (((Note_Usage_Temp.Note_ID)=" & Val(iFootNoteID) & "));") |
| 0253 | If strPrintDuplicateFootnoteRefs = "No" Then |
| 0254 | If rsSecure.EOF Then |
| 0255 | strPrintThisSuperscript = "No" |
| 0256 | Else |
| 0257 | rsSecure.MoveFirst |
| 0258 | If Val(Note_Ref) <> rsSecure.Fields(0).Value Then 'FIX - re "print all" |
| 0259 | strPrintThisSuperscript = "No" |
| 0260 | End If |
| 0261 | End If |
| 0262 | End If |
| 0263 | End If |
| 0264 | End If |
| 0265 | Set rsSecure = Nothing |
| 0266 | 'Find its Notes_Group |
| 0267 | strDirectory = "../" |
| 0268 | If Notes_Group_Name <> "N/A" Then |
| 0269 | 'Determine if across secure area |
| 0270 | Set rsSecure = CurrentDb.OpenRecordset("SELECT Note_Groups.Note_Group FROM Notes INNER JOIN Note_Groups ON Notes.Note_Group = Note_Groups.ID WHERE (((Notes.ID)=" & iFootNoteID & "));") |
| 0271 | If rsSecure.EOF Then |
| 0272 | strDirectory = "../../Notes/" |
| 0273 | Else |
| 0274 | rsSecure.MoveFirst |
| 0275 | If rsSecure.Fields(0) <> Notes_Group_Name Then |
| 0276 | If rsSecure.Fields(0) = "Supervisions" Then |
| 0277 | strDirectory = "../../Secure_Jen/" |
| 0278 | Else |
| 0279 | If Notes_Group_Name = "Supervisions" Then |
| 0280 | strDirectory = "../../Notes/" |
| 0281 | End If |
| 0282 | End If |
| 0283 | End If |
| 0284 | End If |
| 0285 | End If |
| 0286 | FootNoteTimestamp = 0 |
| 0287 | If Last_Changed_Timestamp > 0 Then 'This is either just a flag, or an actual timestamp |
| 0288 | If Last_Changed_Timestamp < 50000 Then |
| 0289 | Last_Changed_Timestamp = 50000000 |
| 0290 | End If |
| 0291 | 'Find latest Timestamp for links |
| 0292 | Set rsLatestTimestamp = CurrentDb.OpenRecordset("SELECT Max(Notes_Archive.Timestamp) AS MaxOfTimestamp FROM Notes_Archive WHERE (((Notes_Archive.Timestamp)<=" & Last_Changed_Timestamp & ")) GROUP BY Notes_Archive.ID HAVING (((Notes_Archive.ID)=" & iFootNoteID & "));") |
| 0293 | If Not rsLatestTimestamp.EOF Then |
| 0294 | rsLatestTimestamp.MoveFirst |
| 0295 | FootNoteTimestamp = rsLatestTimestamp.Fields(0).Value |
| 0296 | End If |
| 0297 | Set rsLatestTimestamp = CurrentDb.OpenRecordset("SELECT Max(Notes_Archive.Timestamp) AS MaxOfTimestamp FROM Notes_Archive WHERE (((Notes_Archive.Timestamp)<=" & Last_Changed_Timestamp & ")) GROUP BY Notes_Archive.ID HAVING (((Notes_Archive.ID)=" & iFootNoteID & "));") |
| 0298 | If FootNoteTimestamp = 0 Then |
| 0299 | Set rsLatestTimestamp = CurrentDb.OpenRecordset("SELECT Min(Notes_Archive.Timestamp) AS MinOfTimestamp FROM Notes_Archive WHERE (((Notes_Archive.Timestamp)>=" & Last_Changed_Timestamp & ")) GROUP BY Notes_Archive.ID HAVING (((Notes_Archive.ID)=" & iFootNoteID & "));") |
| 0300 | If Not rsLatestTimestamp.EOF Then |
| 0301 | rsLatestTimestamp.MoveFirst |
| 0302 | FootNoteTimestamp = rsLatestTimestamp.Fields(0).Value |
| 0303 | End If |
| 0304 | End If |
| 0305 | Set rsLatestTimestamp = Nothing |
| 0306 | End If |
| 0307 | If Ref_Type = "N" Then |
| 0308 | OK = Cross_Reference_Add(Ref_Type, NoteID, Last_Changed_Timestamp, "N", iFootNoteID, FootNoteTimestamp) |
| 0309 | End If |
| 0310 | strControlQuery = "SELECT Notes.[Private?] FROM Notes WHERE (((Notes.ID)=" & iFootNoteID & "));" |
| 0311 | Set rsNoteType = CurrentDb.OpenRecordset(strControlQuery) |
| 0312 | If Not rsNoteType.EOF Then |
| 0313 | If rsNoteType.Fields(0).Value = "Yes" Then |
| 0314 | If IsMissing(strPrintable) Then |
| 0315 | strLink1 = " 0, "_" & FootNoteTimestamp, "") & ".htm" & strRef & """>" |
| 0316 | If WordFound = "Yes" Then |
| 0317 | strLink2 = "" & iSuperscript & "" |
| 0318 | Else |
| 0319 | strLink2 = "" & iSuperscript & "" |
| 0320 | End If |
| 0321 | Else |
| 0322 | If Val(strPrintable) > 0 And strPrintThisSuperscript = "Yes" Then |
| 0323 | strLink1 = "" |
| 0324 | strLink2 = "" & iSuperscript & "" |
| 0325 | Else |
| 0326 | strLink1 = "" |
| 0327 | strLink2 = "" |
| 0328 | End If |
| 0329 | End If |
| 0330 | Else |
| 0331 | If IsMissing(strPrintable) Then |
| 0332 | strLink1 = " 0, "_" & FootNoteTimestamp, "") & ".htm" & strRef & """>" |
| 0333 | If WordFound = "Yes" Then |
| 0334 | strLink2 = "" & iSuperscript & "" |
| 0335 | Else |
| 0336 | strLink2 = "" & iSuperscript & "" |
| 0337 | End If |
| 0338 | Else |
| 0339 | If Val(strPrintable) > 0 And strPrintThisSuperscript = "Yes" Then |
| 0340 | strLink1 = "" |
| 0341 | strLink2 = "" & iSuperscript & "" |
| 0342 | Else |
| 0343 | strLink1 = "" |
| 0344 | strLink2 = "" |
| 0345 | End If |
| 0346 | End If |
| 0347 | End If |
| 0348 | Else |
| 0349 | If IsMissing(strPrintable) Then |
| 0350 | strLink1 = " 0, "_" & FootNoteTimestamp, "") & ".htm" & strRef & """>" |
| 0351 | If WordFound = "Yes" Then |
| 0352 | strLink2 = "" & iSuperscript & "" |
| 0353 | Else |
| 0354 | strLink2 = "" & iSuperscript & "" |
| 0355 | End If |
| 0356 | Else |
| 0357 | If Val(strPrintable) > 0 And strPrintThisSuperscript = "Yes" Then |
| 0358 | strLink1 = "" |
| 0359 | strLink2 = "" & iSuperscript & "" |
| 0360 | Else |
| 0361 | strLink1 = "" |
| 0362 | strLink2 = "" |
| 0363 | End If |
| 0364 | End If |
| 0365 | End If |
| 0366 | z = z + Len(strLink1) + Len(strLink2) - (Y - x + 2) |
| 0367 | If z < 1 Then |
| 0368 | z = 1 |
| 0369 | End If |
| 0370 | If WordFound = "Yes" Then |
| 0371 | If Mid(strLine, x - 1, 1) = " " Then |
| 0372 | TheWord = Mid(strLine, i, x - 1 - i) |
| 0373 | z = z - 1 |
| 0374 | Else |
| 0375 | TheWord = Mid(strLine, i, x - i) |
| 0376 | End If |
| 0377 | If Right(TheWord, 1) = "]" Then |
| 0378 | TheWord = Mid(TheWord, 2, Len(TheWord) - 2) |
| 0379 | End If |
| 0380 | Else |
| 0381 | TheWord = "" |
| 0382 | End If |
| 0383 | strLine = Left(strLine, i - 1) & "" & strLink1 & TheWord & strLink2 & Mid(strLine, Y + 2, Len(strLine)) |
| 0384 | If x > z Then |
| 0385 | iSection = iSection + 1 |
| 0386 | z = InStr(z + 5, strLine, " ") |
| 0387 | If z = 0 Then |
| 0388 | z = 10000000 |
| 0389 | End If |
| 0390 | End If |
| 0391 | x = InStr(x, strLine, "++") |
| 0392 | 'Ignore In-sheet Footnotes |
| 0393 | If x > 0 Then |
| 0394 | No_FN = "No" |
| 0395 | Do Until No_FN = "Yes" |
| 0396 | If x > 0 Then |
| 0397 | If Mid(strLine, x + 2, 2) = "FN" Then |
| 0398 | FN_Start = x |
| 0399 | x = x + 1 |
| 0400 | x = InStr(x, strLine, "++") |
| 0401 | If x > 0 Then |
| 0402 | FN_End = x + 1 |
| 0403 | Footnote_Text = Mid(strLine, FN_Start + 4, FN_End - FN_Start - 5) & "" |
| 0404 | If Footnote_Text <> "" Then |
| 0405 | If Mid(strLine, FN_Start - 1, 1) = " " Then |
| 0406 | i = FindWord(strLine, FN_Start - 1, "]") |
| 0407 | Else |
| 0408 | i = FindWord(strLine, FN_Start, "]") |
| 0409 | End If |
| 0410 | strLink1 = "" |
| 0411 | strLink2 = "" & iSuperscript & "" |
| 0412 | If Mid(strLine, FN_Start - 1, 1) = " " Then |
| 0413 | TheWord = Mid(strLine, i, FN_Start - 1 - i) |
| 0414 | Else |
| 0415 | TheWord = Mid(strLine, i, FN_Start - i) |
| 0416 | End If |
| 0417 | If Right(TheWord, 1) = "]" Then |
| 0418 | TheWord = Mid(TheWord, 2, Len(TheWord) - 2) |
| 0419 | End If |
| 0420 | 'Add to table |
| 0421 | rst.AddNew |
| 0422 | rst.Fields(0) = NoteID |
| 0423 | rst.Fields(1) = iSuperscript |
| 0424 | rst.Fields(2) = Footnote_Text |
| 0425 | rst.Fields(3) = Now() |
| 0426 | rst.Update |
| 0427 | strLine = Left(strLine, i - 1) & strLink1 & TheWord & strLink2 & Mid(strLine, FN_End + 1) |
| 0428 | iSuperscript = iSuperscript + 1 |
| 0429 | End If |
| 0430 | x = x + 1 |
| 0431 | x = InStr(x, strLine, "++") |
| 0432 | End If |
| 0433 | Else |
| 0434 | No_FN = "Yes" |
| 0435 | End If |
| 0436 | Else |
| 0437 | No_FN = "Yes" |
| 0438 | End If |
| 0439 | Loop |
| 0440 | End If |
| 0441 | iSuperscript = iSuperscript + 1 |
| 0442 | Else |
| 0443 | x = x + 1 |
| 0444 | x = InStr(x, strLine, "++") |
| 0445 | End If |
| 0446 | Loop |
| 0447 | If Test_Flag = True Then |
| 0448 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Note Superscripts Created" |
| 0449 | sw2.StartTimer |
| 0450 | End If |
| 0451 | 'Create the Note-Paper links |
| 0452 | OK = Reference_Papers(strLine, Ref_Type, NoteID, Last_Changed_Timestamp) |
| 0453 | If Test_Flag = True Then |
| 0454 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Note-Paper links Created" |
| 0455 | sw2.StartTimer |
| 0456 | End If |
| 0457 | 'Create the Note-Books links |
| 0458 | OK = Reference_Books(strLine, Ref_Type, NoteID, Last_Changed_Timestamp) |
| 0459 | If Test_Flag = True Then |
| 0460 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Note-Book links Created" |
| 0461 | sw2.StartTimer |
| 0462 | End If |
| 0463 | 'Replace the Author References by hyperlinks |
| 0464 | OK = Reference_Author(strLine, Ref_Type, NoteID, Last_Changed_Timestamp) |
| 0465 | If Test_Flag = True Then |
| 0466 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Author links Created" |
| 0467 | sw2.StartTimer |
| 0468 | End If |
| 0469 | 'Replace the Note Links References by hyperlinks |
| 0470 | If IsMissing(strPrintable) Then |
| 0471 | OK = Reference_Note_Links(strLine, Ref_Type, NoteID, Last_Changed_Timestamp) |
| 0472 | Else |
| 0473 | OK = Reference_Note_Links(strLine, "NP", NoteID, Last_Changed_Timestamp) |
| 0474 | End If |
| 0475 | If Test_Flag = True Then |
| 0476 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Note links Created" |
| 0477 | sw2.StartTimer |
| 0478 | End If |
| 0479 | 'Replace References (not sure required ...) |
| 0480 | OK = Reference_Reference(strLine) |
| 0481 | 'Replace References to Code |
| 0482 | OK = Reference_Code(strLine) |
| 0483 | OK = Reference_Code_Bridge(strLine) |
| 0484 | OK = Reference_Tables(strLine) 'Replace Table-references by hyperlinks |
| 0485 | OK = Reference_Queries(strLine) 'Replace Query-references by hyperlinks |
| 0486 | 'Bullets |
| 0487 | strLine = NumberedBullets(strLine) |
| 0488 | strLine = Bullets(strLine) |
| 0489 | 'Colours |
| 0490 | OK = Mark_Colours(strLine) |
| 0491 | 'Weblinks |
| 0492 | If IsMissing(strPrintable) Then |
| 0493 | OK = Reference_Webrefs(strLine, Ref_Type, NoteID, Last_Changed_Timestamp) |
| 0494 | Else |
| 0495 | OK = Reference_Webrefs(strLine, Ref_Type, NoteID, Last_Changed_Timestamp, "Show") |
| 0496 | End If |
| 0497 | strLine = ImageRef(strLine, "Notes", Ref_Type, NoteID, Last_Changed_Timestamp) |
| 0498 | OK = Classification_Change(strLine) |
| 0499 | If Test_Flag = True Then |
| 0500 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Sundry minor referencing" |
| 0501 | sw2.StartTimer |
| 0502 | End If |
| 0503 | 'Log Referencing Changes |
| 0504 | If Full_Regen = False Then |
| 0505 | DoCmd.OpenQuery ("Cross_Reference_Changes_Deletions_Add") |
| 0506 | End If |
| 0507 | If Test_Flag = True Then |
| 0508 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Cross_Reference_Changes_Deletions_Add" |
| 0509 | sw2.StartTimer |
| 0510 | End If |
| 0511 | 'Log Referencing Changes |
| 0512 | If Full_Regen = False Then |
| 0513 | DoCmd.OpenQuery ("Cross_Reference_Changes_Additions_Add") |
| 0514 | End If |
| 0515 | If Test_Flag = True Then |
| 0516 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw2.EndTimer; "Milliseconds"; " Cross_Reference_Changes_Additions_Add" |
| 0517 | sw2.StartTimer |
| 0518 | End If |
| 0519 | If IsMissing(strPrintable) Then |
| 0520 | Cross_Reference_Table_Open = False |
| 0521 | Set rsCross_Reference_Table = Nothing |
| 0522 | DoCmd.OpenQuery ("Cross_Reference_Idempotency_Zap") |
| 0523 | End If |
| 0524 | If Test_Flag = True Then |
| 0525 | Debug.Print Now(); "Notes_Text_Format"; NoteID; Note_Ref; Last_Changed_Timestamp; sw.EndTimer; "Milliseconds" |
| 0526 | End If |
| 0527 | If Test_Flag = True Then |
| 0528 | Set sw = Nothing |
| 0529 | Set sw2 = Nothing |
| 0530 | End If |
| 0531 | Set rst = Nothing |
| 0532 | End Function |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function NumberedBullets(strString) |
| 0002 | Dim iListstart As Long |
| 0003 | Dim iListEnd As Long |
| 0004 | Dim iNextBullet As Long |
| 0005 | Dim strStringTemp As String |
| 0006 | Dim endTag As String |
| 0007 | Dim startTag As String |
| 0008 | Dim i As Long |
| 0009 | Dim j As Long |
| 0010 | Dim strFirstNumber As String |
| 0011 | Dim k As Integer |
| 0012 | Dim Delimiter As String |
| 0013 | Dim Widget As String |
| 0014 | Dim Len_strFirstNumber As Long |
| 0015 | 'Note: to start the numbered list at x other than 1, a, A, i, I, code |xx|y|x|. y is always an arabic number, and can be 0 or negative |
| 0016 | strStringTemp = strString |
| 0017 | For k = 1 To 5 |
| 0018 | iListstart = 1 |
| 0019 | iListEnd = 1 |
| 0020 | Select Case k |
| 0021 | Case 1 |
| 0022 | Delimiter = "|99|" 'Numbers ... has to go first because of the "start over-ride" |
| 0023 | Widget = "1" |
| 0024 | Case 2 |
| 0025 | Delimiter = "|ii|" 'Lowercase Roman |
| 0026 | Widget = "i" |
| 0027 | Case 3 |
| 0028 | Delimiter = "|II|" 'Uppercase Roman |
| 0029 | Widget = "I" |
| 0030 | Case 4 |
| 0031 | Delimiter = "|aa|" 'Lowercase Letters |
| 0032 | Widget = "a" |
| 0033 | Case 5 |
| 0034 | Delimiter = "|AA|" 'Uppercase Letters |
| 0035 | Widget = "A" |
| 0036 | Case Else |
| 0037 | End Select |
| 0038 | OK = Check_Delimiters(strString, Delimiter) |
| 0039 | 'Numbered Lists |
| 0040 | Do While iListstart <> 0 And iListEnd <> 0 |
| 0041 | iListstart = InStr(iListEnd, strStringTemp, Delimiter, vbBinaryCompare) |
| 0042 | If iListstart > 0 Then |
| 0043 | iListEnd = InStr(iListstart + 1, strStringTemp, Delimiter, vbBinaryCompare) |
| 0044 | End If |
| 0045 | If iListstart <> 0 And iListEnd <> 0 Then |
| 0046 | 'Check for start-number over-ride |
| 0047 | 'Note: I have a use of "|0|" for unnumbered bullets in a list, so I have to watch out for confusion between this and a list starting "0" |
| 0048 | startTag = "" |
| 0049 | strFirstNumber = "" |
| 0050 | i = InStr(iListstart + 1, strStringTemp, "|1|") |
| 0051 | j = InStr(iListstart + 1, strStringTemp, "|0|") |
| 0052 | If Mid(strStringTemp, j + 2, 3) = "|1|" Then |
| 0053 | j = 0 |
| 0054 | End If |
| 0055 | If j > 0 Then |
| 0056 | If i > 0 Then |
| 0057 | If j < i Then |
| 0058 | i = j |
| 0059 | End If |
| 0060 | Else |
| 0061 | i = j |
| 0062 | End If |
| 0063 | End If |
| 0064 | If i > iListEnd Then |
| 0065 | i = 0 |
| 0066 | End If |
| 0067 | Len_strFirstNumber = 0 |
| 0068 | If i > 0 Then |
| 0069 | If i - iListstart > 4 Then |
| 0070 | strFirstNumber = Mid(strStringTemp, iListstart + 4, i - iListstart - 4) |
| 0071 | Len_strFirstNumber = Len(strFirstNumber) |
| 0072 | If IsNumeric(Trim(strFirstNumber)) Then |
| 0073 | startTag = "start = """ & Trim(strFirstNumber) & """ " |
| 0074 | Else |
| 0075 | i = iListstart + 4 |
| 0076 | strFirstNumber = "" |
| 0077 | Len_strFirstNumber = 0 |
| 0078 | End If |
| 0079 | End If |
| 0080 | Else |
| 0081 | 'Check to ensure the |1|'s haven't already been stolen by another numbered list! |
| 0082 | i = InStr(iListstart + 1, strStringTemp, "") |
| 0083 | If i > iListEnd Then |
| 0084 | i = 0 |
| 0085 | End If |
| 0086 | If i > 0 Then |
| 0087 | If i - iListstart > 4 Then |
| 0088 | strFirstNumber = Mid(strStringTemp, iListstart + 4, i - iListstart - 4) |
| 0089 | Len_strFirstNumber = Len(strFirstNumber) |
| 0090 | strFirstNumber = Replace(strFirstNumber, "", "") |
| 0091 | If IsNumeric(Trim(strFirstNumber)) Then |
| 0092 | startTag = "start = """ & Trim(strFirstNumber) & """ " |
| 0093 | End If |
| 0094 | End If |
| 0095 | Else |
| 0096 | i = iListstart + 4 |
| 0097 | End If |
| 0098 | End If |
| 0099 | endTag = "" |
| 0100 | strStringTemp = Left(strStringTemp, iListstart - 1) & "" & Mid(strStringTemp, i, Len(strStringTemp)) |
| 0101 | iListEnd = iListEnd - 4 + 13 + Len(startTag) - Len_strFirstNumber |
| 0102 | iNextBullet = InStr(iListstart + 1, strStringTemp, "|1|") |
| 0103 | Do While iNextBullet <> 0 And iNextBullet < iListEnd |
| 0104 | If iNextBullet <> 0 Then |
| 0105 | strStringTemp = Left(strStringTemp, iNextBullet - 1) & endTag & "" & Mid(strStringTemp, iNextBullet + 3, Len(strStringTemp)) |
| 0106 | iListEnd = iListEnd - 3 + Len(endTag) + 4 |
| 0107 | End If |
| 0108 | endTag = "" |
| 0109 | iNextBullet = InStr(iNextBullet + 1, strStringTemp, "|1|") |
| 0110 | Loop |
| 0111 | strStringTemp = Left(strStringTemp, iListEnd - 1) & endTag & "" & Mid(strStringTemp, iListEnd + 4, Len(strStringTemp)) |
| 0112 | iListEnd = iListEnd - 4 + Len(endTag) + 5 |
| 0113 | End If |
| 0114 | Loop |
| 0115 | Next k |
| 0116 | strStringTemp = Replace(strStringTemp, "|0|", "") |
| 0117 | strStringTemp = Replace(strStringTemp, " ", "") |
| 0118 | strStringTemp = Replace(strStringTemp, " ", "") |
| 0119 | NumberedBullets = strStringTemp |
| 0120 | End Function |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Reference_Notes(strText, Calling_Type, Calling_ID, Calling_Timestamp, Optional Depth, Optional strType, Optional strBookPaper, Optional DocID) |
| 0002 | Dim x As Long |
| 0003 | Dim qq As Long |
| 0004 | Dim Y As Long |
| 0005 | Dim z As Long |
| 0006 | Dim yy As Long |
| 0007 | Dim zz As Long |
| 0008 | Dim Noteref As Integer |
| 0009 | Dim Noteref_Text As String |
| 0010 | Dim strText_Local As String |
| 0011 | Dim strText_End As String |
| 0012 | Dim qryString As String |
| 0013 | Dim rsTableToRead As Recordset |
| 0014 | Dim rsNoteID As Recordset |
| 0015 | Dim NotesGroup As Integer |
| 0016 | Dim NoteSubDirectory As String |
| 0017 | Dim iDepth As Integer |
| 0018 | Dim strPrefix As String |
| 0019 | Dim i As Integer |
| 0020 | Dim strPre As String |
| 0021 | Dim strPost As String |
| 0022 | Dim strNoteSource As String |
| 0023 | Dim strLinkText As String |
| 0024 | Dim j As Integer |
| 0025 | Dim No_FN As String |
| 0026 | Dim strText_Ref As String |
| 0027 | Dim TheWord As String |
| 0028 | Dim strName As String |
| 0029 | On Error GoTo ErrorExit |
| 0030 | If Len(strText) = 0 Then |
| 0031 | Reference_Notes = "Not Found" |
| 0032 | Exit Function |
| 0033 | End If |
| 0034 | j = 0 |
| 0035 | If IsMissing(Depth) Then |
| 0036 | iDepth = 2 |
| 0037 | Else |
| 0038 | iDepth = Depth |
| 0039 | End If |
| 0040 | If IsMissing(strType) Then |
| 0041 | strNoteSource = "Abstract" |
| 0042 | Else |
| 0043 | strNoteSource = strType |
| 0044 | End If |
| 0045 | If strNoteSource = "Abstract" Then |
| 0046 | strPre = "+N" |
| 0047 | strPost = "N+" |
| 0048 | Else |
| 0049 | strPre = "++" |
| 0050 | strPost = "++" |
| 0051 | End If |
| 0052 | i = 0 |
| 0053 | strPrefix = "" |
| 0054 | Do While i < iDepth |
| 0055 | strPrefix = strPrefix & "../" |
| 0056 | i = i + 1 |
| 0057 | Loop |
| 0058 | strText_Local = strText |
| 0059 | x = 1 |
| 0060 | x = InStr(x, strText_Local, strPre) |
| 0061 | 'Ignore In-sheet Footnotes |
| 0062 | No_FN = "No" |
| 0063 | Do Until No_FN = "Yes" |
| 0064 | If x > 0 Then |
| 0065 | qq = x |
| 0066 | If Mid(strText_Local, x + 2, 2) = "FN" Then |
| 0067 | x = x + 1 |
| 0068 | j = j + 1 |
| 0069 | x = InStr(x, strText_Local, "++") |
| 0070 | If x > 0 Then |
| 0071 | If x = qq + 4 Then |
| 0072 | 'Ie. have found ++FN++ marker ... so remove it |
| 0073 | strText_Local = Left(strText_Local, qq - 1) & Mid(strText_Local, qq + Len("++FN++"), Len(strText_Local)) |
| 0074 | x = qq |
| 0075 | End If |
| 0076 | x = x + 1 |
| 0077 | x = InStr(x, strText_Local, strPre) |
| 0078 | End If |
| 0079 | Else |
| 0080 | No_FN = "Yes" |
| 0081 | End If |
| 0082 | Else |
| 0083 | No_FN = "Yes" |
| 0084 | End If |
| 0085 | Loop |
| 0086 | 'If strPre = +N, we need to watch out for ++NP, when strPost of N+ won't be found! |
| 0087 | '... Hopefully this can be achieved by calling this routine in the right sequence ************* |
| 0088 | Reference_Notes = "Not Found" |
| 0089 | If strNoteSource = "Abstract" Or strNoteSource = "Abstract_Direct" Then |
| 0090 | If Not IsMissing(strBookPaper) Then |
| 0091 | If strBookPaper = "Book" Then |
| 0092 | 'Set up Note_Book_Links Recordset, if necessary |
| 0093 | If NoteBookLinksDB_Open <> "Open" Then |
| 0094 | NoteBookLinksDB_Open = "Open" |
| 0095 | Set rsNoteBookLinksDB = CurrentDb.OpenRecordset("SELECT Note_Book_Links.* FROM Note_Book_Links WHERE (((Note_Book_Links.Note)=999999));") |
| 0096 | End If |
| 0097 | 'Delete any old Note_Book_Links |
| 0098 | DoCmd.RunSQL ("DELETE Note_Link_Zapper3.* FROM Note_Link_Zapper3;") |
| 0099 | DoCmd.RunSQL ("INSERT INTO Note_Link_Zapper3 ( [Note], Note_Ref, [Object], [Timestamp],ObjectType ) SELECT Note_Book_Links.Note, Note_Book_Links.Note_Ref, Note_Book_Links.Book, Note_Book_Links.Timestamp, Note_Book_Links.Origin FROM Note_Book_Links WHERE (((Note_Book_Links.Book)=" & DocID & ") AND ((Note_Book_Links.Origin)=""Book""));") |
| 0100 | DoCmd.RunSQL ("DELETE Note_Book_Links.* FROM Note_Book_Links INNER JOIN Note_Link_Zapper3 ON (Note_Book_Links.Timestamp = Note_Link_Zapper3.Timestamp) AND (Note_Book_Links.Book = Note_Link_Zapper3.Object) AND (Note_Book_Links.Note_Ref = Note_Link_Zapper3.Note_Ref) AND (Note_Book_Links.Note = Note_Link_Zapper3.Note) AND (Note_Book_Links.Origin = Note_Link_Zapper3.ObjectType);") |
| 0101 | DoCmd.RunSQL ("DELETE Note_Link_Zapper3.* FROM Note_Link_Zapper3;") |
| 0102 | Else |
| 0103 | If strBookPaper = "Paper" Then |
| 0104 | 'Set up Note_Paper_Links Recordset, if necessary |
| 0105 | If NotePaperLinksDB_Open <> "Open" Then |
| 0106 | NotePaperLinksDB_Open = "Open" |
| 0107 | Set rsNotePaperLinksDB = CurrentDb.OpenRecordset("SELECT Note_Paper_Links.* FROM Note_Paper_Links WHERE (((Note_Paper_Links.Note)=999999));") |
| 0108 | End If |
| 0109 | 'Delete any old Note_Paper_Links |
| 0110 | DoCmd.RunSQL ("DELETE Note_Link_Zapper3.* FROM Note_Link_Zapper3;") |
| 0111 | DoCmd.RunSQL ("INSERT INTO Note_Link_Zapper3 ( [Note], Note_Ref, [Object], [Timestamp],ObjectType ) SELECT Note_Paper_Links.Note, Note_Paper_Links.Note_Ref, Note_Paper_Links.Paper, Note_Paper_Links.Timestamp, Note_Paper_Links.Origin FROM Note_Paper_Links WHERE (((Note_Paper_Links.Paper)=" & DocID & ") AND ((Note_Paper_Links.Origin)=""Paper""));") |
| 0112 | DoCmd.RunSQL ("DELETE Note_Paper_Links.* FROM Note_Paper_Links INNER JOIN Note_Link_Zapper3 ON (Note_Paper_Links.Timestamp = Note_Link_Zapper3.Timestamp) AND (Note_Paper_Links.Paper = Note_Link_Zapper3.Object) AND (Note_Paper_Links.Note_Ref = Note_Link_Zapper3.Note_Ref) AND (Note_Paper_Links.Note = Note_Link_Zapper3.Note) AND (Note_Paper_Links.Origin = Note_Link_Zapper3.ObjectType);") |
| 0113 | DoCmd.RunSQL ("DELETE Note_Link_Zapper3.* FROM Note_Link_Zapper3;") |
| 0114 | End If |
| 0115 | End If |
| 0116 | End If |
| 0117 | End If |
| 0118 | If x > 0 Then |
| 0119 | 'Watch out for C++!! This could be more sophisticated ... a fudge for now! |
| 0120 | If Mid(strText_Local, x - 1, 1) = "C" And Mid(strText_Local, x - 2, 1) = " " And Not IsNumeric(Mid(strText_Local, x + 2, 1)) Then |
| 0121 | If Mid(strText_Local, x, 4) <> "++++" And Mid(strText_Local, x, 4) <> "+NN+" Then |
| 0122 | x = InStr(x + 1, strText_Local, strPre) |
| 0123 | End If |
| 0124 | End If |
| 0125 | End If |
| 0126 | Do While x > 0 |
| 0127 | j = j + 1 |
| 0128 | z = x |
| 0129 | Reference_Notes = "Found" |
| 0130 | If Mid(strText_Local, x + 2, 2) = "NP" Then |
| 0131 | x = x + 2 |
| 0132 | Y = InStr(x, strText_Local, strPost) |
| 0133 | Else |
| 0134 | Y = InStr(x + 1, strText_Local, strPost) |
| 0135 | End If |
| 0136 | 'Check for embedded in-page references |
| 0137 | If Y = 0 Or (Y - x) > 10 Then |
| 0138 | If Y = 0 Or (Y - x) > 85 Then |
| 0139 | Debug.Print Now() & " - "; Mid(strText_Local, x, 100) |
| 0140 | MsgBox "Reference_Notes: post-reference missing" |
| 0141 | Stop |
| 0142 | Else |
| 0143 | 'check for references |
| 0144 | zz = InStr(Mid(strText_Local, x + 1, Y - x), "#") |
| 0145 | If zz = 0 Then |
| 0146 | Debug.Print Now() & " - "; Mid(strText_Local, x, 100) |
| 0147 | MsgBox "Reference_Notes: post-reference missing" |
| 0148 | Stop |
| 0149 | End If |
| 0150 | End If |
| 0151 | End If |
| 0152 | zz = InStr(x + 1, strText_Local, "#") |
| 0153 | strText_Ref = "" |
| 0154 | If zz > 0 Then |
| 0155 | If zz < Y Then |
| 0156 | strText_Ref = Mid(strText_Local, zz + 1, Y - zz - 1) |
| 0157 | End If |
| 0158 | End If |
| 0159 | zz = Len(strText_Ref) |
| 0160 | If zz > 0 Then |
| 0161 | zz = zz + 1 |
| 0162 | End If |
| 0163 | If Y - x - 2 - zz < 1 Then |
| 0164 | 'Check this is the "++++" or "+NN+" or "++NP++" case where we have to look up the reference *************** |
| 0165 | If Mid(strText_Local, x, 4) = "++++" Or Mid(strText_Local, x, 4) = "+NN+" Or Mid(strText_Local, x, 2) = "NP" Then |
| 0166 | yy = FindWord(strText_Local, x, "]") |
| 0167 | 'Find the key-word(s) |
| 0168 | TheWord = Mid(strText_Local, yy, x - yy) |
| 0169 | If Right(TheWord, 1) = "]" Then |
| 0170 | TheWord = Mid(TheWord, 2, Len(TheWord) - 2) |
| 0171 | End If |
| 0172 | 'Find the Note ID. NB uses the Note_Alternates table! |
| 0173 | Set rsNoteID = CurrentDb.OpenRecordset("SELECT Notes.ID FROM Note_Alternates INNER JOIN Notes ON Note_Alternates.Item_Title = Notes.Item_Title WHERE (((Note_Alternates.Item_Alt_Title)=""" & TheWord & """));") |
| 0174 | If rsNoteID.EOF Then |
| 0175 | Noteref_Text = "1256" 'The "dud links" Note! |
| 0176 | Else |
| 0177 | rsNoteID.MoveFirst |
| 0178 | Noteref_Text = rsNoteID.Fields(0) |
| 0179 | End If |
| 0180 | Set rsNoteID = Nothing |
| 0181 | strText_Local = Left(strText_Local, x + 1) & Noteref_Text & Mid(strText_Local, x + 2) |
| 0182 | If Mid(strText_Local, x, 2) = "++" Then |
| 0183 | Y = Y + 1 + Len(Noteref_Text) |
| 0184 | Else |
| 0185 | Y = Y + Len(Noteref_Text) |
| 0186 | End If |
| 0187 | Noteref = Noteref_Text |
| 0188 | End If |
| 0189 | Else |
| 0190 | Noteref_Text = Mid(strText_Local, x + 2, Y - x - 2 - zz) |
| 0191 | Noteref = Noteref_Text |
| 0192 | End If |
| 0193 | If Y > Len(strText_Local) - 2 Then |
| 0194 | strText_End = "" |
| 0195 | Else |
| 0196 | strText_End = Mid(strText_Local, Y + 2, Len(strText_Local)) |
| 0197 | End If |
| 0198 | If Len(strText_Ref) > 0 Then |
| 0199 | strText_Ref = "#Off-Page_Link_" & strText_Ref |
| 0200 | End If |
| 0201 | If Calling_Type <> "X" Then |
| 0202 | OK = Cross_Reference_Add(Calling_Type, Calling_ID, Calling_Timestamp, "N", Noteref, 0) |
| 0203 | End If |
| 0204 | 'Determine if Secure or Not |
| 0205 | qryString = "SELECT Notes.Note_Group FROM Notes WHERE (((Notes.ID)=" & Noteref & "));" |
| 0206 | Set rsTableToRead = CurrentDb.OpenRecordset(qryString) |
| 0207 | If Not rsTableToRead.EOF Then |
| 0208 | rsTableToRead.MoveFirst |
| 0209 | NotesGroup = rsTableToRead.Fields(0).Value |
| 0210 | Else |
| 0211 | NotesGroup = 0 |
| 0212 | End If |
| 0213 | 'Determine the Notes_Directory |
| 0214 | NoteSubDirectory = Find_New_Directory(Noteref) |
| 0215 | 'Set up the link |
| 0216 | qq = 0 |
| 0217 | TheWord = "" |
| 0218 | If strNoteSource = "Abstract" Or strNoteSource = "Abstract_Direct" Then |
| 0219 | If strNoteSource = "Abstract" Then |
| 0220 | If Mid(strText_Local, z - 1, 1) = "(" Or Mid(strText_Local, z - 1, 1) = " " Or Mid(strText_Local, z - 1, 1) = "|" Then |
| 0221 | strLinkText = "Click here for Note" |
| 0222 | Else |
| 0223 | qq = FindWord(strText_Local, z - 1, "]") |
| 0224 | If qq > 0 Then |
| 0225 | TheWord = Trim(Mid(strText_Local, qq, z - qq)) |
| 0226 | If Right(TheWord, 1) = "]" Then |
| 0227 | TheWord = Mid(TheWord, 2, Len(TheWord) - 2) |
| 0228 | End If |
| 0229 | qq = z - qq |
| 0230 | If Len(TheWord) > 0 Then |
| 0231 | strLinkText = TheWord & "" |
| 0232 | End If |
| 0233 | End If |
| 0234 | End If |
| 0235 | Else |
| 0236 | qq = FindWord(strText_Local, z - 1, "]") |
| 0237 | strLinkText = "" & j & "" |
| 0238 | If qq > 0 Then |
| 0239 | TheWord = Trim(Mid(strText_Local, qq, z - qq)) |
| 0240 | If Right(TheWord, 1) = "]" Then |
| 0241 | TheWord = Mid(TheWord, 2, Len(TheWord) - 2) |
| 0242 | End If |
| 0243 | qq = z - qq |
| 0244 | If Len(TheWord) > 0 Then |
| 0245 | strLinkText = TheWord & "" & j & "" |
| 0246 | End If |
| 0247 | End If |
| 0248 | End If |
| 0249 | If Not IsMissing(strBookPaper) Then |
| 0250 | 'Add new Link |
| 0251 | If strBookPaper = "Book" Then |
| 0252 | rsNoteBookLinksDB.AddNew |
| 0253 | rsNoteBookLinksDB.Fields(0) = Noteref |
| 0254 | rsNoteBookLinksDB.Fields(1) = 0 |
| 0255 | rsNoteBookLinksDB.Fields(2) = DocID |
| 0256 | rsNoteBookLinksDB.Fields(3) = 0 |
| 0257 | rsNoteBookLinksDB.Fields(4) = strBookPaper |
| 0258 | rsNoteBookLinksDB.Fields(5) = Now() |
| 0259 | On Error Resume Next |
| 0260 | '... ********** in case of duplicates |
| 0261 | rsNoteBookLinksDB.Update |
| 0262 | On Error GoTo ErrorExit |
| 0263 | Else |
| 0264 | If strBookPaper = "Paper" Then |
| 0265 | rsNotePaperLinksDB.AddNew |
| 0266 | rsNotePaperLinksDB.Fields(0) = Noteref |
| 0267 | rsNotePaperLinksDB.Fields(1) = 0 |
| 0268 | rsNotePaperLinksDB.Fields(2) = DocID |
| 0269 | rsNotePaperLinksDB.Fields(3) = 0 |
| 0270 | rsNotePaperLinksDB.Fields(4) = strBookPaper |
| 0271 | rsNotePaperLinksDB.Fields(5) = Now() |
| 0272 | On Error Resume Next |
| 0273 | '... ********** in case of duplicates |
| 0274 | rsNotePaperLinksDB.Update |
| 0275 | On Error GoTo ErrorExit |
| 0276 | End If |
| 0277 | End If |
| 0278 | End If |
| 0279 | Else |
| 0280 | strLinkText = "" & j & "" |
| 0281 | End If |
| 0282 | If Calling_Type = "X" Then |
| 0283 | strName = "" |
| 0284 | Else |
| 0285 | strName = "N" & Noteref & "_" & OK |
| 0286 | strName = "" |
| 0287 | End If |
| 0288 | If NotesGroup <> 10 Then |
| 0289 | strText_Local = Left(strText_Local, z - 1 - qq) & strName & "" & strLinkText & strText_End |
| 0290 | Else |
| 0291 | strText_Local = Left(strText_Local, z - 1 - qq) & strName & "" & strLinkText & strText_End |
| 0292 | End If |
| 0293 | Set rsTableToRead = Nothing |
| 0294 | x = InStr(x, strText_Local, strPre) |
| 0295 | If x > 0 Then |
| 0296 | 'Watch out for C++!! This could be more sophisticated ... a fudge for now! |
| 0297 | If Mid(strText_Local, x - 1, 1) = "C" And (Not IsNumeric(Mid(strText_Local, x + 2, 1)) And Mid(strText_Local, x + 2, 2) <> "NP") Then |
| 0298 | If Mid(strText_Local, x, 4) <> "++++" And Mid(strText_Local, x, 4) <> "+NN+" Then |
| 0299 | x = InStr(x + 1, strText_Local, strPre) |
| 0300 | End If |
| 0301 | End If |
| 0302 | End If |
| 0303 | 'Ignore In-sheet Footnotes |
| 0304 | No_FN = "No" |
| 0305 | Do Until No_FN = "Yes" |
| 0306 | If x > 0 Then |
| 0307 | qq = x |
| 0308 | If Mid(strText_Local, x + 2, 2) = "FN" Then |
| 0309 | x = x + 1 |
| 0310 | j = j + 1 |
| 0311 | x = InStr(x, strText_Local, "++") |
| 0312 | If x > 0 Then |
| 0313 | If x = qq + 4 Then |
| 0314 | 'Ie. have found ++FN++ marker ... so remove it |
| 0315 | strText_Local = Left(strText_Local, qq - 1) & Mid(strText_Local, qq + Len("++FN++"), Len(strText_Local)) |
| 0316 | x = qq |
| 0317 | End If |
| 0318 | x = x + 1 |
| 0319 | x = InStr(x, strText_Local, strPre) |
| 0320 | End If |
| 0321 | Else |
| 0322 | No_FN = "Yes" |
| 0323 | End If |
| 0324 | Else |
| 0325 | No_FN = "Yes" |
| 0326 | End If |
| 0327 | Loop |
| 0328 | Loop |
| 0329 | strText = strText_Local |
| 0330 | Exit Function |
| 0331 | ErrorExit: |
| 0332 | Reference_Notes = "Error" |
| 0333 | strLinkText = "Error in Sub Reference_Notes: Type=" & IIf(IsMissing(strType), "Missing", strType) & "; Book / Paper=" & IIf(IsMissing(strBookPaper), "Missing", strBookPaper) & "; DocID=" & IIf(IsMissing(DocID), "Missing", DocID) |
| 0334 | strLinkText = strLinkText & "; Error = " & Err.Number & " (" & Err.Description & ")" |
| 0335 | Debug.Print Now() & " - " & strLinkText |
| 0336 | MsgBox strLinkText |
| 0337 | Stop |
| 0338 | End Function |