John Gr Posted March 26, 2010 Share Posted March 26, 2010 H there i am in the process of creating a script that would access an external data file. The data file uses a comma deliminator format. I would like to READ this data into VW script. As far i can see VW only uses a TAB deliminator. Any ideas... cheers John Greaney Win Vista 2008 Quote Link to comment
Pat Stanford Posted March 26, 2010 Share Posted March 26, 2010 I think you will have to write your own parsing routine. Use StdRead or StdReadLn to get the data into a variable and then run through it looking for commas. Sam Jones and John McKernon are probably the leading experts in getting data into and out of VW. Maybe one of them will chime in. If you need help with the parsing, just ask and I am sure we can come up with a solution. How much data do you need to bring in? If it is only a few items, then speed does not really matter. If it is thousands of lines, speed will be of more concern. Quote Link to comment
MullinRJ Posted March 26, 2010 Share Posted March 26, 2010 Hi John, I do this a lot. Here is a sample script. You'll have to add a loop and a READLN() to import multiple records. HTH, Raymond PROCEDURE ParseIt; { Copyright 2010 Raymond J. Mullin } CONST Comma = ','; VAR S, T :String; param1 : Integer; param2 : Real; param3 : String; param4 : Boolean; function GetParam (var S :String; Delim :Char) :String; { Return the first substring of S up to the Delim character, } { and delete the substring from S. } Var DelimPos : Integer; Begin DelimPos := pos(Delim, S); if (DelimPos > 0) then GetParam := copy(S, 1, DelimPos-1); delete(S, 1, DelimPos); end else GetParam := ''; End; { GetParam } function UpperStr (S :String) :String; { Return UPPER CASE of String S. } Begin UprString(S); UpperStr := S; End; { UpperStr } BEGIN S := concat(7, Comma, 15.2, Comma, 'Texty Stuff', Comma, 'True'); { test string } T := S; { a copy of S } S := concat(S, Comma); { add a delimeter to the end of S if one is not already there } param1 := Str2Num(GetParam(S, Comma)); param2 := Str2Num(GetParam(S, Comma)); param3 := GetParam(S, Comma); param4 := UpperStr(GetParam(S, Comma)) = 'TRUE'; message(T, ' ---> ', param1, ' ', param2, ' ', param3, ' ', param4); END; Run(ParseIt); Quote Link to comment
John Gr Posted March 29, 2010 Author Share Posted March 29, 2010 Hi there Guys Thanks for your replies. I will try the code you have posted. I have added the file that contains the data i require. The data is at the end of the file. the last 2 lines. The data contains fixing details for a particular truss. GT1. Thanks Again John Greaney Quote Link to comment
MullinRJ Posted March 29, 2010 Share Posted March 29, 2010 Hi John, ???You will have to set up a loop to read every record until you find the one with: NoBearings=2 Use the POS() function to identify it and exit your loop. Then read the next two records and dissect each one accordingly. Have fun, Raymond 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.