Jump to content
Developer Wiki and Function Reference Links ×

Hex Bolt (Inch) Code


Recommended Posts

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

Link to comment

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);

Link to comment
  • 2 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...