3

I am working on some HTML code that was inherited from another programmer, which uses include statements of the form:

~inc:filename.inc~

However, the problem I am encountering is that this include statement does not work reliably. About 90% of the time, all information in the included file is imported with no problem, but every so often all of that content goes missing when I refresh the page and comes back in when I refresh again. I have already tried changing the include statements to more widely-used forms such as:

<!-- FILE="filename.inc"-->
<!-- virtual="../filename.inc"-->
<!-- virtual="/filename.inc"-->

but this only results in the file consistently not being included at all. I have been poking around other places on the Internet, but can't seem to find any solutions or even any usage of of the '~inc:' include statement.

It is worth noting that this HTML is being loaded from firmware hosted on low-power equipment and certain items on the page are updating regularly. Is it possible that the updating methods are simply running too fast for the hardware to handle?

Does anyone have any ideas for how I can solve this problem?

4

1 に答える 1

0

わかりましたので、アプリケーション ライブラリのドキュメントをダウンロードして調べたところ、次の関数TCPIP Stack Help.chmが見つかりました。HTTPIncFile

void HTTPIncFile(ROM BYTE* cFile);

ユーザーはこの関数を直接呼び出すべきではありませんが、その代わりに HTML コードに ~inc:filename.ext~ の形式で動的変数を追加して、指定された場所にファイル「filename.ext」を含める必要があります。MPFS2 Generator ユーティリティが残りを処理します。

したがって、元の構文だけが文書化されているようです。関数を直接呼び出さないようにと書かれていますが、問題があるため、同じ結果が得られるかどうかを確認する価値があるかもしれません。

また、次の点にも注意してください。

curHTTP.callbackPos が 0 の場合、ファイルが開かれ、可能な限り多くのバイトが書き込まれます。次に、現在の位置が curHTTP.callbackPos に保存され、ファイルが閉じられます。以降の呼び出しでは、保存された場所から読み上げが開始され、続行されます。入力ファイルの最後に到達すると、完了を示すために curHTTP.callbackPos が 0 に戻されます。

これは単なる憶測ですが、ファイルを複数回含めようとしたり、同時に 1 つ以上のファイルを含めようとしたりすると、問題が発生する可能性があります。ファイルが含まれていない場合は、callbackPosがリセットされていないことが原因である可能性があります。また、テンプレート ファイルを変更しようとしているわけではないと想定していましたが、次のように言いました。

ページの特定のアイテムは定期的に更新されています

含めたいファイルが変更されている場合は、同時実行の問題が発生している可能性があります。これが起こらないことを確認するためにロックまたは同期に頼る必要があるかもしれません。または、正の数のバイトが正常に含まれるまで、オフセットをチェックして include メソッドで待機スピンを試みる必要があるかもしれません。

于 2011-06-06T11:31:51.720 に答える