Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 11:39 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: OpusScript
PostPosted: November 8th, 2005, 1:01 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

With the help of the DW team, I am trying to move forward on scritping the diagram maker using object cloning that I've been working on. Trying to now apply the script to a second (frame) object, both to clone it (and its 4 sub-parts), save these and read and reset them to show again, is the next challenge.

When I apply the script that works to a second object (changing/renaming what I believe to be all of the variables), I keep getting an error pop-up in preview saying object not found, the called object is not a valid object. I can clone and hide its color vector sub-parts OK, but it won't write to disk file (that one place the error message pops-up) nor read/reset from text file (the other place where the error message pops-up).

code

write:

//
save = ref + ",";

for (loop=0;loop<ref;loop++)
{
var pos = myClone[loop].GetPosition();

// String of data for this object
var objdata = pos.x + "," + pos.y;

// Go through the children, saving their states
var child = myClone[loop].GetFirstChild();
while (child)
{
objdata += "," + child.m_state;

child = myClone[loop].GetNextChild(child);
}

// Add the objet data to the output string
save += objdata;

// Comma between items but not at the end
if (loop < (ref - 1))
{
save += ",";
}
}

for each sub-part/vector state:

if (this.m_state == 0)
{
this.m_state = 1;
this.SetTransparency(0); // Solid
}
else if (this.m_state == 1)
{
this.m_state = 0;
this.SetTransparency(100); // Transparent
}

and for each sub-part/vector

this.m_state=1

What needs to be changed/renamed for a new object (for example, called frameb)?

Any ideas how to adapt a complex working script to a second (and third, fourth...) object?


Thanks for your help.

Kind Regards,
Stephen[code][/code]


Top
 Profile  
 
 Post subject:
PostPosted: November 8th, 2005, 2:33 pm 
Offline

Joined: October 26th, 2004, 10:23 am
Posts: 666
Location: Digital Workshop
The code I wrote is almost entirely portable. The problem is that you have presumably renamed the myClone array to something else. You need to create that array before using it. See the On Show action on the Clone button on the first page.

_________________
ddww Opus Developer


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 8th, 2005, 4:02 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

Thanks for that lead. Once I made the change on the first page, it worked OK.

When I got to the second page, where a button reads the text files (I set up one for each object-frame, framea and frameb) and the diagram is displayed, it isn't working correctly.

I've written 3 scripts for this read/display button on page 2:

#1

// Open the saved data
textobj = OpenFile("c:\\pos\\pos.txt");


// Number of objects
ref = textobj.ReadField(false);

for (loop = 0; loop < ref; loop++)
{
// Position
x = textobj.ReadField(false);
y = textobj.ReadField(false);

// Clone the object at the new pos
myClone[loop] = frame.CloneObject(x,y,true);

// Set the states of the children
var child = myClone[loop].GetFirstChild();
while (child)
{
// Load the state and save it in this object
var state = textobj.ReadField(false);
child.m_state = String.integer(state);

// Set visibility
if (child.m_state == 0)
child.SetTransparency(100);
else
child.SetTransparency(0);

// Next child...
child = myClone[loop].GetNextChild(child);
}
}

#2

// Open the saved data
textobj = OpenFile("c:\\pos\\posa.txt");


// Number of objects
ref = textobj.ReadField(false);

for (loop = 0; loop < ref; loop++)
{
// Position
x = textobj.ReadField(false);
y = textobj.ReadField(false);

// Clone the object at the new pos
myClone[loop] = framea.CloneObject(x,y,true);

// Set the states of the children
var child = myClone[loop].GetFirstChild();
while (child)
{
// Load the state and save it in this object
var state = textobj.ReadField(false);
child.m_state = String.integer(state);

// Set visibility
if (child.m_state == 0)
child.SetTransparency(100);
else
child.SetTransparency(0);

// Next child...
child = myClone[loop].GetNextChild(child);
}
}

#3

// Open the saved data
textobj = OpenFile("c:\\pos\\posb.txt");


// Number of objects
ref = textobj.ReadField(false);

for (loop = 0; loop < ref; loop++)
{
// Position
x = textobj.ReadField(false);
y = textobj.ReadField(false);

// Clone the object at the new pos
myClone[loop] = frameb.CloneObject(x,y,true);

// Set the states of the children
var child = myClone[loop].GetFirstChild();
while (child)
{
// Load the state and save it in this object
var state = textobj.ReadField(false);
child.m_state = String.integer(state);

// Set visibility
if (child.m_state == 0)
child.SetTransparency(100);
else
child.SetTransparency(0);

// Next child...
child = myClone[loop].GetNextChild(child);
}
}

Result: It overlaps all three objects, 3 times, instead of one display of each without the others overlapping it.

If I can figure this button out, from there, it's simply a matter of adding more objects, repeating the codes over and over.

I would appreciate any help with this seemingly last obstacle.

Again, I greatly appreciate your kind assistance.

Stephen


Top
 Profile  
 
 Post subject:
PostPosted: November 8th, 2005, 4:17 pm 
Offline

Joined: October 26th, 2004, 10:23 am
Posts: 666
Location: Digital Workshop
You are overwriting the contents of myClone three times.

_________________
ddww Opus Developer


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 8th, 2005, 4:43 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Duncan

When I remove the second and third scripts from page 2's read/display button, it then will only display the object labelled "frame." The remaining 2 saved objects, framea and frameb, don't get read or displayed on page 2.

Can I add framea and frameb to the script in the page 2 read/display button in any way without ruining the remaining scripting (for example as

myClone[loop] = framea.CloneObject(x,y,true);

and

myClone[loop] = frameb.CloneObject(x,y,true);

or some other script?

I need to get all 3 objects, created on page 1 and saved, to read and display on page 2.

Thanks, again for your kind help

Stephen


Top
 Profile  
 
 Post subject:
PostPosted: November 8th, 2005, 11:15 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

Just a little clarification:

what I am trying to provide for the viewer is the ability to construct their own diagram. Several type diagram symbols (objects including circles, squares, lines, etc.) would need to be available for the viewer to pick from, as many as 40 varieties, maybe more. A few of the diagram symbols also would allow the viewer to click on a color quadrant, either hiding or showing that particular quadrant. All symbols would need to be capable of then being cloned as many times as needed by viewer choice.

Then the viewer can drag and drop a variety/number of these symbols to wherever they wish on the diagram. Before navigating from the page, all dragged and dropped symbols' positions and states of quadrant display (whether showing or hidden) would need to be saved to disk files.

Then upon returning to the page later, a reset button would summon positions and quadrant display states for dragged and dropped clones, place them in their positions, with the correct color quadrants showing.

My experimental version has 3 cloneable symbols: square, circle, diamond, each with 4 color quadrants. So far, I can clone them, hide/show qaudrants. It's unclear if the problem lies in the code saving/writing to disk file or with the code to read/display these afterwards. I've gotten them to where they can all display, but their positioning is off since they are stacked one atop the other.

I hope this clarifies the project somewhat. So close, yet still a bit off.

All help is appreciated.

Kind Regards,
Stephen


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

All times are UTC [ DST ]


Who is online

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