Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently November 6th, 2024, 6:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Whats wrong with this page script?
PostPosted: July 16th, 2007, 11:46 pm 
Offline

Joined: March 8th, 2005, 9:40 pm
Posts: 63
Hi,

With the following code (on a page), the page just freezes. I realise that I need some sort of loop on the page, to continue, but I am not sure how to do this. (I have never done any sort of programming before, except for batch files, in which I could use "GOTO")

If there was a “SWITCH” function, I think that I could more easily have achieved what I need to do.

I managed to do some of what I require without Opusscript, using select/case (similar to Switch/case), but this would have resulted in a clumsy programme with a lot more work, not only when writing the program, but also when trying to update it, which is fairly regularly.

Here is my script, which obviously has errors. If the sections commented on with // are removed, the script works initially, but “freezes” after the first phase.

I realise that the entire script is very clumsy, but I am trying to learn how to write Opusscript. (any recommendations would be appreciated)

I struggled to refer to a variable from a variable, so I used "read first line from file" to set <tloc> and "read next line from file" to set <loc_t> instead. A cop-out, I know, that may slow the programme down, but it worked.

The first document (set by variable) refered to in the script has a first line as "1,1,0,0,1,0,1,0," and a second line as "9" The second line is used to set the variable <loc_t>

The 2nd document (set by variable) refered to in the script has a first line as "0,1,0,1,0,1,0,1," and a second line as "1000" The second line is used to set the variable <loc_t> The reason I used 1000 for the second variable is that the user is able to toggle LE_1 as many times as they want before pressing a button to exit this component.


Code:
C:\Documents and Settings\Nitro\My Documents\My Prog\<loc_new>.txtvar get_loc;
get_loc = tloc;
var cloc = new Array(<loc_t>) //loc_t is a variable, I was trying to set the length.
var cloc = get_loc.split(',');
var floc = cloc[0];
var L1 = cloc[1];
var L2 = cloc[2];
var L3 = cloc[3];
if (floc == "0")
  if (L1 == "1") 
  {LE_1.Show()}
  if (L1 == "0")
  {LE_1.Hide}
  for (loop = 1;loop<cloc.length;loop++) // this creates a problem.
if (floc == "1")
  if (L1 == "1") 
  {LE_1.Show()
   LE_2.Show()}
  if (L1 == "0")
  {LE_1.Hide}
  for (loop = 1;loop<cloc.length;loop++) // this creates a problem.
else
{LE_8.Show()}
for (loop = 1;loop<cloc.length;loop++) // this creates a problem.
Please help...

Neil


Top
 Profile  
 
 Post subject:
PostPosted: July 17th, 2007, 10:04 am 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 511
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
had a very quick look at the script and the first thing I spot is...you are missing curly brackets in the FOR loops and IF statements.

Hope you don't mind if I make a suggestion which would help you greatly. The layout of your script is very poor and that's why it's difficult to see this type of problem. I have difficulty seeing what you are trying to do in the script---statements need to be indented to show structure and normally opening and closing curly brackets are at the same indent level so it's easier to match then. It is also common to comment closing curlys. The precise method of layout is very much personal preference, but it make faultfinding much easier.

There is a select in the Programming actions, but not in script.

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject:
PostPosted: July 23rd, 2007, 12:18 am 
Offline

Joined: March 8th, 2005, 9:40 pm
Posts: 63
Hi Sandyn,

Thanks for the info. I know my profile states that I joined in 2005.
I did.
I looked at the programme, but did not have a specific use for it at the time. I recently had a possible use for it, and decided to see if Opus could help me. As I have had no programming experience, your comments helped me.

I have subsequently managed to achieve what I wanted, by studying Javascript 1.1 on the net.

I wish to thank you for looking at my post, and commenting on this.

Regards

Neil


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group