Re: Variable Error
Re: Variable Error
- Subject: Re: Variable Error
- From: Deivy Petrescu <email@hidden>
- Date: Fri, 26 Feb 2010 14:00:39 -0500
On 26/02/2010, at 13:10 , Richard Lake wrote:
> Hi,
>
> Without giving you the whole script and associated product data etc.. I shall try recreate an example here and explain the problem I am having in Applescript code.
>
> set top to my readfile(a file somewhere containing <HTML> ,<head>, title, meta info etc before main content)
> set bottom to my readfile(a file somewhere containing footer eg. </BODY> and stuff below it)
>
> I use the FindAndReplace routines to replace '||' with quote marks and replace '~~' with a linefeed; this all works fine. So what we end up with
> is two variables with delimiters of \" where the quote marks are etc. and nicely paragraphed html code.
>
> code example:
>
> set top to my readfile(a file somewhere containing HTML head data, title, meta info etc)
> set bottom to my readfile(a file somewhere containing footer eg. </BODY> and stuff below it)
>
> read products from csvs into corresponding arrays
>
> set htmlfile to {}
> set bodytext to ""
>
> set end of htmlfile to top
>
> repeat with each product in array
>
> set bodytext to bodytext & the product as a <table> to appear in the webpage
> set bodytext to findandreplace("~~", return, bodytext)
> set bodytext to findandreplace("||", quote, bodytext)
>
> set end of htmlfile to bodytext - FAILS here
>
> set end of htmlfile to bottom
>
> at 10th product exit repeat
>
> end repeat
>
> write to disc
>
> ----
>
> So now i have 3 variables, top bodytext and bottom which all contain the applescript marker for a quote mark... \"
>
> htmlfile should contain all 3 parts together.
>
> Now when the program reaches the line ('set end of htmlfile to bodytext') I get the message: 'Can't set end of htmlfile (html code in top) to (bodytext).'
>
> Now I have of course used 'return htmlfile' and 'return bodytext' to ensure they are correct, but I cannot get past this 'Can set end of htmlfile...' message.
>
> I don't really have a clue why this is happening, I thought it was something to do with the quote marks in the variables, but I even commented out the
> FindAndReplace calls and still hit the error.
>
> Richard, Beaver Promotions
>
Richard,
There can be many problems that prevent the text to be added at the end of the list.
Quotes can be one such problem.
However, if you are interested in text, why not use a text instead of a list
set htmlfile to top
repeat with each product in array
set bodytext to bodytext & the product as a <table> to appear in the webpage
set bodytext to findandreplace("~~", return, bodytext)
set bodytext to findandreplace("||", quote, bodytext)
set htmlfile to htmlfile & return & bodytext
set end of htmlfile to bottom ---> are you sure this is inside the repeat loop ?
at 10th product exit repeat
end repeat
Deivy Petrescu
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Automator-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden