Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 6:18 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Do...
PostPosted: September 8th, 2007, 2:09 am 
Offline

Joined: March 8th, 2005, 9:40 pm
Posts: 63
I am anticipating someone to shoot me down on this :roll: , and tell me why this is not required, or how a “for” or nested “if” loops can do this, :oops: but, putting my brave face on… :twisted: . Remember I am not a programmer! :oops:
How about a “Do” function? :D

_________________
Opus Pro V6
Dell Inspiron 9400
Intel Centrino Duo 2GHz
2 Gig Ram
XP SP2


For this message Nitro has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: September 8th, 2007, 5:43 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Run out of bullets :-) but isn't do part of the while structure that already exists in Opus you just don't need to type the actual word 'do'?

Now if you want to cause an uproar, how about a case statement - nested ifs are just a pain in the behind :-)

Going back to the sunshine.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Case
PostPosted: September 8th, 2007, 7:00 pm 
Offline

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

I already suggested a case (switch) statement in one of my posts, and was told to use nested ifs.

Thanks for the info on "while". I have tried to avoid for and while statements, as I seem to have a mental block against these.

:D

Regards

Neil

_________________
Opus Pro V6
Dell Inspiron 9400
Intel Centrino Duo 2GHz
2 Gig Ram
XP SP2


For this message Nitro has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: September 8th, 2007, 9:33 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
Hi Nitro,
I suggested using nested if's -- but when there isn't any choice....

cheers
Paul


For this message Paul has been thanked by : mackavi


Last edited by Paul on September 15th, 2007, 11:37 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: September 9th, 2007, 10:52 pm 
Offline

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

Please do not misunderstand me. I really appreciate any advice that I get. Even more, I appreciate the fact that you, Mack and others take the time to respond to novices queries.

Thanks for the Tutorial on Loops. My mental block is that I (think) I understand the basics on how to do these, but am lost as to when to do these. My application does not require a lot of loops.

When I think that a loop would result in more efficient coding, suddenly I am at a loss on how to implement this.

Take the following example; I am sure that a loop would have provided more efficient coding.

Code:
Kpress = "0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,"
len = Kpress.length
Debug.trace(len+"\n")

var itemdesc = new String(Kpress);
var myArray = itemdesc.split(",");

    if(len < 3)
    var item1 = "00";
    var item2 = "00";
    var item3 = "00";
    var item4 = "00";
    var item5 = "00";
    var item6 = "00";
    var item7 = "00";
    var item8 = "00";
    var item9 = "00";



//1
    if((len >= 3 )&&(len < 7)){
    var item1 = myArray[0]+ myArray[1];
    var item2 = "00";
    var item3 = "00";
    var item4 = "00";
    var item5 = "00";
    var item6 = "00";
    var item7 = "00";
    var item8 = "00";
    var item9 = "00";
    }
//2
    if((len >= 7 )&&(len < 11)){
    var item1 = myArray[0]+ myArray[1];
    var item2 = myArray[2]+ myArray[3];
    var item3 = "00";
    var item4 = "00";
    var item5 = "00";
    var item6 = "00";
    var item7 = "00";
    var item8 = "00";
    var item9 = "00";
    }
//3
   if((len >= 11 )&&(len < 15)){
    var item1 = myArray[0]+ myArray[1];
    var item2 = myArray[2]+ myArray[3];
    var item3 = myArray[4]+ myArray[5];
    var item4 = "00";
    var item5 = "00";
    var item6 = "00";
    var item7 = "00";
    var item8 = "00";
    var item9 = "00";
    }
//etc
 

Full details on Post: viewtopic.php?t=2828&highlight=

This should probably have looked something like:

Code:
Kpress = "0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,"
len = Kpress.length
Debug.trace(len+"\n")

var itemdesc = new String(Kpress);
var myArray = itemdesc.split(",");
var itemArray

If (len < 3) {
  for (i=1;i<=9;i++){
      var itemArray[i] = “00”
  }
}

if((len >= 3 )&&(len < 7)){
  for (i=2;i<=9;i++){
       var itemArray[1] = myArray[0]+ myArray[1];
       var itemArray[i] = “00”
  }
}
if((len >= 7 )&&(len < 11)){
  for (i=3;i<=9;i++){
       var itemArray[1] = myArray[0]+ myArray[1];
       var itemArray[2] = myArray[1]+ myArray[2];
       var itemArray[i] = “00”
  }
}
//Etc…

I am not sure how to create a blank array.
My guess would be:
Code:
var item = new string()
var itemArray = item.split(“,”)


I am not sure if this would work, I am just trying to get past my mental block on loops. When I have tried to impliment these in the past, I have had problems.

Thanks again for your input. It really is appreciated!

Regards

Neil

_________________
Opus Pro V6
Dell Inspiron 9400
Intel Centrino Duo 2GHz
2 Gig Ram
XP SP2


For this message Nitro has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: September 10th, 2007, 12:57 am 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
Hi Nitro,
Loops will give you shorter coding, but it will not be more efficient.
Looking at your script, I would not try to "improve" it by using loops.
I only use loops if a very regular pattern can be seen, otherwise you end up doing a lot of work for no actual improvement.
Things can get very complicated very quickly.
There is nothing wrong with using the script you wrote as it is.

Paul


For this message Paul has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: September 10th, 2007, 5:21 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Nitro,

Just a little answer...

To create a new blank array use:

myArray = new Array()


You can specific the number of elements, but it's not necessary.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: v7 now has switch(arg) & case "abc":
PostPosted: January 29th, 2010, 2:11 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Quote:
Mackavi: Now if you want to cause an uproar, how about a case statement - nested ifs are just a pain in the behind

Nitro: I already suggested a case (switch) statement in one of my posts, and was told to use nested ifs.


Now see, patience and loyalty pays off. And 'Wishlists' do work. Fine job DW!! This will really be a productivity tool.

I almost 'missed' this in the New Features listing. Now in OpusPro v7 --- code from the 'cycle' sample pub
Code:
   switch(style)
   {
   case "rainbow":
      colour[0]= RGB(224,0,15)
      colour[1]= RGB(255,0,0)
      colour[2]= RGB(255,85,0)
      colour[3]= RGB(255,170,0)
      colour[4]= RGB(255,224,0)
      colour[5]= RGB(255,255,0)
      colour[6]= RGB(224,255,0)
      colour[7]= RGB(170,255,0)
      colour[8]= RGB(85,255,0)
      colour[9]= RGB(0,255,0)
      colour[10]= RGB(10,245,10)
      colour[11]= RGB(0,255,85)
      colour[12]= RGB(0,255,170)
      colour[13]= RGB(0,255,224)
      colour[14]= RGB(0,224,224)
      colour[15]= RGB(0,170,255)
      colour[16]= RGB(0,85,255)
      colour[17]= RGB(0,0,255)
      colour[18]= RGB(10,10,224)
      colour[19]= RGB(85,0,255)
      colour[20]= RGB(100,0,224)
      colour[21]= RGB(150,0,180)
      colour[22]= RGB(170,0,65)
      colour[23]= RGB(196,0,35)
      break;
   case "rainbow quad":
               //**** it continues with similar set of colour values
:)

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 32 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