newbarndesign Posted November 7, 2002 Share Posted November 7, 2002 What would the code sequence be to enable a plugin to utilized Tab Delimited text files for information. I see in the Hex Bolt plug in support files that it can be done. I just can not find any where in the documentation how to use those resources. I am writing a similar style of plug in and really need to figure it out. Thanks Phil Quote Link to comment
Alexandre Villares Posted November 8, 2002 Share Posted November 8, 2002 Have a look at the Filie I/O procedures at the VS Function Reference. Quote Link to comment
MullinRJ Posted November 8, 2002 Share Posted November 8, 2002 I'm not sure if there are any differences when accessing files from Plug-Ins, but here is a script that will read and write prefs to a tab delimited text file. Sorry about the loss of indentation, it is a victim of this BB. HTH, Raymond Procedure SaveToFile; { Read variables from file. Save new variables if they change. This example saves 2 Reals and an Integer to a tab delimited text file. } CONST FileName = 'RAM Disk:Defaults'; Tb = chr(9); { TAB character } VAR SaveDefaults :Boolean; Int, SavedInt :Integer; X, Y, SavedX, SavedY :Real; Function GetDefaults :Boolean; { Get defaults from file or create them if file does not exist. In VW8.5.2 (Mac), a Caution Dialog appears when the Pref file does not exit, but a new file is created anyway. Clear the dialog and continue. } VAR B :Boolean; Begin Open(FileName); if (GetLastFileErr=0) & not EOF(FileName) then begin Readln(SavedX, SavedY, SavedInt); B := False; end else begin { Initialize defaults if Pref file does not exist } SavedX := 6.5; SavedY := 3.8; SavedInt := 3; B := True; end; Close(FileName); GetDefaults := B; { Will force Pref file to be saved when true } End; { End GetDefaults } Procedure SetDefaults; { Rewrite the Pref file with new values. } Begin Rewrite(FileName); Writeln(X:6:3, Tb, Y:6:3, Tb, Int:1); Close(FileName); End; { End SetDefaults } BEGIN SaveDefaults := GetDefaults; { Read in saved variables } PtDialog('Enter a coordinate. Values must fit on drawing.', num2str(3, SavedX), num2str(3, SavedY), X, Y); if not DidCancel then begin Int := IntDialog('Enter an integer value:', num2str(0, SavedInt)); if not DidCancel then if SaveDefaults | (X<>SavedX) | (Y<>SavedY) | (Int<>SavedInt) then begin { Save prefs and BEEP } SetDefaults; SysBeep; end; end; END; { End SaveToFile } Run(SaveToFile); Quote Link to comment
newbarndesign Posted November 19, 2002 Author Share Posted November 19, 2002 Thank You, I will try it out as soon as possible. Unfortunately I have been given another priority project. Thanks Phil Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.