Is there a way to replace variables within a .asp file? The problem I'm having is that the file starts with <% and ends with %> so FB tries to replace the variables, it tries to replace everything between the %.
I've been able to get this to work using Text replacement, but it seems there should be a way to use variable replacement.
Thanks for your post. You’re correct that the % signs cause problems.
The best way to correct this is to escape the individual % signs as %%. Then FinalBuilder will expand these to %, and will expand any other variable references normally.
I"m a little confused by that…i have an asp files that I only want to have 1 % sign - if I add two then the file doesn’t function.
Even with .NET - if I want to iterate through all the files to replace all the variables then this: <%@ Page Language=“C#” MasterPageFile="~/_master/web.master" AutoEventWireup=“true” CodeFile=“auto_schedule.aspx.cs” Inherits=“auto_schedule” Title=“Schedule Preference” %>
will cause problems. I can’t escape the % because then the page won’t work.
Does that make sense? What is the suggested method of variable replacement in this instance?
Thanks for the reply. If you escape the variables as %% in the Original file, then after you do the “Replace Variables” then they will all be single % signs, and any variables (ie %MyFinalBuilderVariable%) will be replaced with their values.
So you can use the file with %%s as the “before” file, and the %s as the “after” file.
Is this OK for you? Or do you need the “before” file to be valid .asp as well?
What I"m saying is I have a .asp file with something like this:
<% 'create connection Dim objConn Set objConn= Server.CreateObject("ADODB.Connection") objConn.Open = "DSN=DSNName; UID=UserId;PWD=%password%;" %>
So when I try to replace %password% it tries to replace what's between the <% and %> because it thinks the % start variables.
Does that make sense?
I can't do:
<%% 'create connection Dim objConn Set objConn= Server.CreateObject("ADODB.Connection") objConn.Open = "DSN=DSNName; UID=UserId;PWD=%password%;" %%>
Because that will neither be a valid file before OR after the variable replacement. But yes, it needs to be valid both before AND after the replacement (simply with the wrong password).
Is there a way for Final Builder to ignore the % if preceeded by a < or follwed by a >?
Thanks for clarifying. This is a tricky thing to work around, for the reasons I outlined earlier (FinalBuilder can’t tell the difference between one % sign and another without escaping.)
If you only need to replace a handful of variables then I would recommend using a different syntax and search for the values specifically.