Technical to read the external text in Director

zhaozj2021-02-16  56

Record, read external text often contact in multimedia creation, usually used to record user information, dynamic change program use text information, etc. Here we will briefly summarize the use of external text in Director. Reading external text preparation: Create two plain text files "c: /data.txt", "c: /data.cus", the content is three: 1. Use plugin: Fileio .x32fileio.x32 is a plugin that is included by Director, which can be read, written. The following functions implement the read a plain text file. None related to file suffix name: on aggetpref thefilename - Establish XTRA instance fileoutin = new (XTRA "fileio") - Detects to successfully generate XTRA instances, return information -1 if not objectp (fileoutin) Then Return -1 End IF - Open external text file fileoutin.openfile (thefilename, 1) - read text data filetxt = fileoutin.readfile () - Close file fileoutin.closefile () - Clear XTRA instance fileoutin = void from memory If the result of the read is empty, the text does not exist, return results - 1 if filetxt = VOID THEN RETURN-1 ELSE RETURN FILETXT END IFEND Example: The following instruction reads the external plain text format file C: /Data.cus, this Text content is "this is text file!" (You can build this file yourself) PUT AGETPREF ("C: /Data.cus") - "this is text file!" Tip: Irritable text not related to the name of the complex name File, we can disappear the "format" of your own program. Although it is plain text, we can also perform special treatment, so that the general user cannot use it directly. 2. The filename property of the actor assumes that there is already a text actor "word" in your movie. Then the following code reads the text in the file c: /data.txt to the internal, becoming the text content of the actor "Word": MEMBER ("Word"). FileName = "C: /Data.txt" Note: When using this method, there must be an operational actor. That is to say, it is achieved by the way to modify the external connection target of an actor. At the same time, when the text reads the actor, this external file is not directly related. Tip: This method can only use TXT, RTF text files, and cannot customize the file suffix name. If you read "C: /Data.cus", the actor will not be available. From this we can also know that the support of Director for external files is first based on the judgment of the file after the file. 3. Using instructions: ImportFileintoImportFileinto allows Director to import external elements through the LingO instruction, including all media elements supported by Director. The following is a code that acquires external text with this instruction: ImportFileinto Member 11, "Data.txt" Tip: The target actor involved in this method can exist without existence. Director will be automatically created for non-unsteaded target actors. If the target actor already exists, the original actor is replaced.

转载请注明原文地址:https://www.9cbs.com/read-21664.html

New Post(0)