Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 7:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Delet text line
PostPosted: October 7th, 2009, 3:31 pm 
Offline

Joined: January 23rd, 2006, 2:57 pm
Posts: 55
Location: Belfast
Opus: 9.5
OS: Win 7
System: i7 8G ram
Hi Folks
Im taking names from a database and adding them to a text box, a new line for each name varlist+=(varName + "\n") This works fine but I would like if the same name comes up again to delete it (and its space) from the text box. Hope this is understandable.
Cheers
Paul


Top
 Profile  
 
 Post subject:
PostPosted: October 7th, 2009, 3:46 pm 
Offline
Godlike
Godlike
User avatar

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

Read the data into an array, sort it then, then filter it it to a new array checking that the entry read isn't the same as the last entry in the new array.

Use this to populate the textbox.

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:
PostPosted: October 7th, 2009, 8:13 pm 
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:
Im taking names from a database

If you are using SQL, you can eliminate duplicates during the query. DISTINCT.

http://www.tizag.com/sqlTutorial/sqldistinct.php
There are better tutorials and examples out there... this one is more or less generic.
Code:
SELECT DISTINCT customer
FROM orders
WHERE day_of_order BETWEEN '7/31/08' AND '9/1/08';

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


Top
 Profile  
 
 Post subject:
PostPosted: October 8th, 2009, 11:04 am 
Offline

Joined: January 23rd, 2006, 2:57 pm
Posts: 55
Location: Belfast
Opus: 9.5
OS: Win 7
System: i7 8G ram
Thx folks for the swift replies they sound great and would be even better if I knew what you are talking about. But thats my problem, I will look into the array thingeys and let you know how I fare. Sorry Lar SQL sounds too scary(at the moment).
Cheers
Paul


Top
 Profile  
 
 Post subject:
PostPosted: October 8th, 2009, 11:40 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
The SQL route can be easier depending on the set-up of your database.

1. What type of database is it? EG MS Access?
2. Do you have access to the database to make changes?
3. Are you using Opus Actions or Script to access the database?

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:
PostPosted: October 8th, 2009, 11:55 am 
Offline

Joined: January 23rd, 2006, 2:57 pm
Posts: 55
Location: Belfast
Opus: 9.5
OS: Win 7
System: i7 8G ram
Hi Mack
Im using MS Access which I have access to and Im using actions for communication. I have no knoweldge of SQL and a smidgen of script.


Top
 Profile  
 
 Post subject:
PostPosted: October 8th, 2009, 1:35 pm 
Offline
Godlike
Godlike
User avatar

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

I think in this case the script for the arrays might be easier. Access can use SQL by creating a query, but if memory serves me correctly, then Opus actions cannot access the query :-)

The script for the array is as follows:

var xArray = new Array(1,2,3,4,5,2,4,7,8,9) //Temp Array
var yArray = new Array() //Array used for text box
var a=0 // Counter


xArray.sort() //Sort the temp array before starting

for (i=0;i<xArray.length;i++) //create a loop the length of temp array
{
if (xArray[i]!=yArray[a-1]) //create to see if current cell value matches last cell value
{
yArray[a]=xArray[i] //if above is true copy current cell values between arrays
a++ //increment counter
}




}

Debug.trace(yArray) //shows the final array in a debug screen

Read your data into the xArray at the start instead of the numbers and then use the yArray at the end to feed the textbox instead of the debug.

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:
PostPosted: October 8th, 2009, 1:59 pm 
Offline

Joined: January 23rd, 2006, 2:57 pm
Posts: 55
Location: Belfast
Opus: 9.5
OS: Win 7
System: i7 8G ram
Hi Mack
Heading to Dublin for a long weekend(YES!!!) will give it a go and let you know hopfully Monday. It will be a hard choice though Guinness or Arrays, hmmmm let me think now.
Thank to all
Cheers
Paul


Top
 Profile  
 
 Post subject:
PostPosted: October 12th, 2009, 8:51 am 
Offline

Joined: January 23rd, 2006, 2:57 pm
Posts: 55
Location: Belfast
Opus: 9.5
OS: Win 7
System: i7 8G ram
Hi Mack

Your script worked fine but my expaination of the problem was flawed. So here we go....

If I have 6 names entered in the textbox from my database eg

Ichabod Crane
Hansel Mc Gretel
Jack Frost
Rumpel Stiltskin
Goldi Locks
Jack Beanstalk

If I try to enter Jack Frost again from the database to the textbox.
The list returned would be...

Ichabod Crane
Hansel Mc Gretel
Rumpel Stiltskin
Goldi Locks
Jack Beanstalk

ie Jack Frost has been deleted.

Will look into text.Selection etc in the meantime.

Does this make sense.


Cheers
Paul


Top
 Profile  
 
 Post subject:
PostPosted: October 12th, 2009, 9:41 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Maybe he's off chasing golden eggs?

Serious, no it doesn't make sense. Adding more than one instance to the original array shouldn't cause a value to vanish. If you post the Imp, I'll have a peek later on.

Mack

var xArray = new Array('Ichabod Crane','Hansel Mc Gretel','Jack Beanstalk','Jack Frost','Rumpel Stiltskin','Goldi Locks','Jack Beanstalk','Jack Beanstalk') //Temp Array
var yArray = new Array() //Array used for text box
var a=0 // Counter


xArray.sort() //Sort the temp array before starting

for (i=0;i<xArray.length;i++) //create a loop the length of temp array
{
if (xArray[i]!=yArray[a-1]) //create to see if current cell value matches last cell value
{
yArray[a]=xArray[i] //if above is true copy current cell values between arrays
a++ //increment counter
}




}

Debug.trace(yArray.join("\n")) //shows the final array in a debug screen

_________________
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:
PostPosted: October 12th, 2009, 10:02 am 
Offline

Joined: January 23rd, 2006, 2:57 pm
Posts: 55
Location: Belfast
Opus: 9.5
OS: Win 7
System: i7 8G ram
Hi Mack

Sorry 3rd time lucky.
So here we go again....

This is what I would like to happen.

If I have 6 names entered in the textbox from my database eg

Ichabod Crane
Hansel Mc Gretel
Jack Frost
Rumpel Stiltskin
Goldi Locks
Jack Beanstalk

If I try to enter Jack Frost again from the database to the textbox.
The list returned would be...

Ichabod Crane
Hansel Mc Gretel
Rumpel Stiltskin
Goldi Locks
Jack Beanstalk

ie Jack Frost has been deleted.



Does this make sense.


Cheers
Paul


Top
 Profile  
 
 Post subject:
PostPosted: October 12th, 2009, 10:54 am 
Offline
Godlike
Godlike
User avatar

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

Got that bit, but I'm guessing that you are not reading the values from the database into the Array.

In which case, how are the values entered into the text box. You need more information on the whole process or an example.

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:
PostPosted: October 12th, 2009, 3:24 pm 
Offline

Joined: January 23rd, 2006, 2:57 pm
Posts: 55
Location: Belfast
Opus: 9.5
OS: Win 7
System: i7 8G ram
Hi Mack

Can I run this passed you.

Button 1 takes name from database to varName.

Button 2 has the following:

varNameHold+=(varName+"\n");
TextName.ReplaceSelection(varNameHold);

This adds the name to texbox TextName eg

Ichabod Crane
Hansel Mc Gretel
Jack Frost
Rumpel Stiltskin
Goldi Locks
Jack Beanstalk

Button3 has:

var selectedArea = TextName.GetSelection(varName)
startSelection = selectedArea.start;
endSelection = selectedArea.end;
TextName.SetSelection(startSelection,endSelection);
TextName.ReplaceSelection("");

If a name is replicated this should(I think) delete it eg Jack Frost

TextName then contains.

Ichabod Crane
Hansel Mc Gretel
Rumpel Stiltskin
Goldi Locks
Jack Beanstalk

But as usuall I cant quite seem to get it to work.

Do you think Im on the right path???

Paul


Top
 Profile  
 
 Post subject:
PostPosted: October 12th, 2009, 5:41 pm 
Offline
Godlike
Godlike
User avatar

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

I think it's an interesting idea, but if I recall, it gets tricky using those commands depending on whether the box is a standard text box or input.

I've merged your idea with the array script and uploaded to our site:

http://www.live.interaktiv.co.uk/goto.php?link=rough

Regards,

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:
PostPosted: October 13th, 2009, 8:16 am 
Offline

Joined: January 23rd, 2006, 2:57 pm
Posts: 55
Location: Belfast
Opus: 9.5
OS: Win 7
System: i7 8G ram
Hi Mack
Cant check out the download, Gobbledygook.
Paul


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

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