Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Scripts and Link Restrictions

8 years ago
I was hoping that other thread would answer my question, but sadly it did not.

I need to modify a variable in the script for a specific page, then use that variable to restrict the links on that page. However, that doesn't seem to work.

On this page script, I can set X to zero. If I display X on the page, it shows up as zero. But when I put a link restriction that says only show the link when X is zero, the link does not display. It works perfectly fine if I set X to zero BEFORE the script on that page. Unfortunately, there is more than one way to get to this page, and I really need to calculate X in the script on this specific page.

Has anyone tried to do this or had any experience with this sort of thing?

Scripts and Link Restrictions

8 years ago

Have you tried using X as any other number other than zero for the link restriction? Also, link scripts gets executed when you click the link, and page scripts execute when the page loads. 

Scripts and Link Restrictions

8 years ago

... I literally cannot process this for some reason. I'm willing to help, but you're either gonna have to explain a different way or show me.

Scripts and Link Restrictions

8 years ago

Basically, he's trying to use a variable for the link restriction, and it's not working out well for him. He's using the value zero for his variable, for the link restriction, and I thought maybe that was why it wasn't working properly, and told him to use any other values. If that still won't work, I guess he'll have to find out whether the value is actually the value he wanted it to be or not. And if the value is the value that he was trying to get for the link restriction, and it still doesn't work, then I would tell him to check the link restriction to make sure that he's setting it to the value that he wanted to restrict it by. 

Scripts and Link Restrictions

8 years ago

Using 0 shouldn't be a problem, though. Although he could try "less than one" as the restriction instead. Sometimes if the editor's glitching, it's better to try a work around like that...

Scripts and Link Restrictions

8 years ago

I had the same problem as you. What if you tried...
IF %X = [number] THEN $PAGEDEST := @P[number]

(probably written incorrectly, but hopefully it still makes sense)

Scripts and Link Restrictions

8 years ago

^ goes into the link script, to be clear--though that could be problematic depending on the links / pages. (Not in a technical way.)

Scripts and Link Restrictions

8 years ago

Yeah, that was an important detail I probably should have stated. Thanks, Kiel.

Scripts and Link Restrictions

8 years ago

Np.

Scripts and Link Restrictions

8 years ago

Script Code Reference. Page scripts are the last scripts to be run, meaning they are executed after links are restricted and even after on-page coding is processed. You'll likely need to use a link script.

Scripts and Link Restrictions

8 years ago

What BD said. Basically,

Link Script changes to Variable happen as you click the link and go into the new Page.

Page Script changes to Variable are the same - meaning that they happen as you leave the Page you are on (just like when you click a link).

In other words, you can't use a Page Script to set Link Restriction on the same Page.

Scripts and Link Restrictions

8 years ago
Dang it. Thanks for all the help folks, that answer was what I was afraid of -- that I simply cannot do it in that page script.

Since the page can be reached from more than one other page, using a link script would be horribly ugly (can you say "copy and paste" to every possible page -- there are about 5 or 6 so far). Ugh. I guess I'll see if I can add an additional page, a temporary page, that will run a link script and basically just have a "continue" to the real page that will have the link limitations.

Thanks again!