codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  really lost my syntax  neverland at 14:28 on Friday, June 06, 2008
 

I have a certain VBA file in which I want to change 2 things automatically (this file is automatically generated and I don't want to change it manually over and over again)

Suppose the name of this file is
BAS_IN.bas

and the contents are:
Function AsianOption(Optional SpotVector As Variant, _
Optional Fixings As Variant, _
Optional InterestVector As Variant, _
Optional DividendVector As Variant, _
Optional Interest As Variant, _
Optional ParameterMatrix As Variant, _
Optional Strike As Variant, _
Optional ObservationTimes As Variant, _
Optional Product As Variant, Optional Model As Variant, _
Optional Greeks As Variant, Optional NSims As Variant, _
Optional continuous As Variant, _
Optional Nobs As Variant) As Variant
Dim Price, GreekValues As Variant

On Error Goto Handle_Error
Call InitModule
If ProductLibclass Is Nothing Then
Set ProductLibclass = CreateObject( "ProductLib.ProductLibclass.1_0")
End If
Call ProductLibclass.AsianOption( _
1, Price, GreekValues, SpotVector, Fixings, InterestVector, _
DividendVector, Interest, ParameterMatrix, Strike, _
ObservationTimes, Product, Model, Greeks, NSims, continuous, Nobs)
AsianOption = Price
Exit Function
Handle_Error:
AsianOption = "Error in " & Err.Source & ": " & Err.Description
End Function


I want to replace ".1_0" by nothing (so delete it)

and then, I want to get rid of those line continuations _ to some extent at least

In this automatically generated file, there are too many of those VBA line continuations. But I suppose there is a limit to how many characters you can have in one line, so I would like to remove them, under the constraint that the line does not get longer than xxx characters.

The output should go to
OUT_BAS.bas

From my memory, I know that this is really easy to do in Perl, but I can't do it anymore

I would be really happy

  Re: really lost my syntax  mimir at 11:26 on Saturday, June 07, 2008
 

#First you want to get the whole file into a variable.

open(RFILE, "<BAS_IN.bas");
while(<RFILE>){$thefile.= $_;}


#the you get rid of that 1.0
$thefile =~ s/(ProductLibclass)\.1_0")/$1/gi;


#and to remove _ its just
$thefile =~ s/_//gi;


open (WFILE, ">>OUT_BAS.bas")
print WFILE "$thefile";










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Array within array
•  Hey all could some 1 help me ?? thanks
•  Re: Checking for a File that Does Not Exist (Yet)
•  mouse trailer
•  Problems in login using WWW::Mechanize
•  using javascript to embed videos
•  Re: really lost my syntax
•  Urgent:- Please help me out with error XML:Parser no element found
•  Urgent:- Please help me out with error XML:Parser no element found


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008