Digital Workshop

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: How to create input Form where number of Fields varies
PostPosted: January 7th, 2009, 2:02 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
I am trying to figure out a way to change the number of INPUT BOXES that will show on a FORM, depending on the number of Fields in the DB Table.

Right now I have Text_Input boxes ( QuickBiuld >>> Create (opus) Table >>> Assign Array variable ). Let's say it's simply 1 column with 8 boxes stacked.

If the database Table has only 5 fields, I might figure out script to hide some boxes. But what if I wanted more input fields for a different Table, say 15 fields? How would I begin to set that up? ( I do have Array vars for FieldNames and for a SampleRecord... so 'array_xx.length' is available.)

Related but not complete:
viewtopic.php?t=2355&highlight=input+box+number
viewtopic.php?t=2376&highlight=input+box+number


( I know the 'sensible' thing to do is create a separate Form for each Table and hard-code the SQL queries for each. But I've been toying with something more 'adaptable' on-the-fly. I have not ventured into the Cloning learning-curve.)

Thanks in advance.

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


Top
 Profile  
 
 Post subject:
PostPosted: January 7th, 2009, 9:47 am 
Offline
Godlike
Godlike
User avatar

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

I think that the two obvious solutions are covered in your links. The 'extra' boxes is a little messy but would work if you don't have too many possible extras.

The clone route is perfect until you realise that the input variable is cloned and thus your boxes lose their uniqueness. Duncan's suggestion here is spot on. Ignore the variable aspect and copy the contents into an array - or better still use OOP to attach the contents to the object.

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: January 7th, 2009, 11:40 am 
Offline

Joined: January 19th, 2005, 5:15 pm
Posts: 83
Location: Netherlands
Hi Mackavi,

What do you mean with OOP in opus? OOP = Object Oriented Programming, which you can't do in opus, right ?


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

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

Yes Object Oriented Programming. Probably not the full blown OOP of other major languages such as Java, but similar to JavaScript in that you can create objects both on screen (host objects) and in the code (native and user-defined objects).

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: January 7th, 2009, 11:46 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
Thx Reem and Mack.

Quote:
Ignore the variable aspect and copy the contents into an array - or better still use OOP to attach the contents to the object.
I don't understand this. Copy...? Is that diff than set EQ? OOP... as in extend some object with added '.properties'? Might be good to know a little more what you mean.

I do have already a working method for ONE text-input box. A prior step to DB Update is that I have a ListBox displaying a current DB record ('record under edit'). Clicking on a data-value in the LB puts that VALUE in the text-input box to revise/edit and simultaneously sets the 'active FieldName' to pass to the SQL statement. (then 'commit' executes)

example: click on "ABC Distributors" in ListBox... sets the DB Field to be updated: CompanyName

I just wanted to move beyond that layout. So a User could simply Tab to next empty box and input new data. Esp. for new record Inserts.


Quote:
The clone route is perfect until you realise that the input variable is cloned and thus your boxes lose their uniqueness.

I don't mind having all input boxes same physical size. And SQLite does not care whether the entered VALUE is text, numeric, or mixed.
- am I missing something here?
- re: cloning... for this situation, can you point me to a prior Post that covered this? (btw, I'm pretty comfortable with arrays manipulations now. Cloning and knowing when to destroy... yet to be learned.)

Cheers.

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


Top
 Profile  
 
 Post subject:
PostPosted: January 8th, 2009, 3:54 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
OOP does what is says on the tin (pun from British Ad). It makes one or more objects the focus of the program. OOP becomes advantageous when the structure of the program begins to become more complex.

In terms of what it does, yes - the additional .properties is one of the principles and probably the most useful in creating a highly structural program out weighting arrays and other variables.

For example; lets say you need to store the information on text input boxes. The information needed is current value, last five previously entered values and dates of update. You have several options - create loads and loads of variables like this;

myTextBoxOneCurrentValue
myTextBoxOnePreviousOneValue
myTextBoxOnePreviousOneDateChange
myTextBoxOnePreviousTwoValue
myTextBoxOnePreviousTwoDateChange
myTextBoxOnePreviousThreeValue
myTextBoxOnePreviousThreeDateChange

Clearly this method works, but becomes very difficult to manage. You could then attempt to achieve this using arrays and thus reduce the amount of variables but still store all the data.

myArrayCurrentValues[x]
myArrayPreviousOneValues[x]
myArrayPreviousOneChanges[x]

Now instead of of individual values for everything, they become collective. All the current text input box values are held in the array myArrayCurrentValues[x] at a position relating to the text input box. IE box zero at position zero.

You can use this method together with sensible naming and the 'eval' statement to achieve much more complex programs. But by using OOP you can reduce the collection either further.

myTextBoxes[x]

Into this array, you place objects. These objects can be existing host objects (such as text input boxes) or cloned host objects or user defined objects.

Each object in every array element is then assigned properties - in our example this would be current value, previous values and date changes.

Now rather than have to find the right variable or right array, you simply need to know the position of the object in the array. The information regarding that object is thus accessible from the array in that same way that using the objects 'name' would be BUT because it's a property of host object it can be easily accessed directly from the physical (I use the term loosely) object (the text input box) on screen using the 'this' key word.

A trick I frequently use when storing host objects in any array (or clones) is to create a property that indexes the position of the object in the array thus when I click on a host object on screen, I know where that host object has been stored.

User defined objects - are simply objects that are not host (IE frames, text boxes, etc) or native (IE array, date, etc) but are created by the programmer for the purpose of storing and manipulating data.

For example; if you wanted a new array object you might type;

myArray = new Array ('fish',cat','dog','mouse') and you'd have a new array object with those four elements.

but you could also create objects specific to your program. Quizzes are probably the most popular Opus activity and can easily be developed using user defined objects.

A quiz is made up of various questions each of which has a question and an answer. Therefore, you create an object called 'quizCard' and assign the properties '.question' and '.answer'

You then start creating new quizCards()

myQuestionOne = new quizCard("what is...","thirty-five")
myQuestionTwo = new quizCard("How did...","by flying")

Clearly, storing these new quizCard objects in variables is daft - so simply use an array.

myQuizQuestions[0] = new quizCard("what is...","thirty-five")
myQuizQuestions[1] = new quizCard("How did...","by flying")

You now have a very simply but powerful way of handling the entire quiz. The array can be quickly randomised AND the questions and answers stay together rather than trying to randomise separate question and answer arrays.

Additional properties can easily be added at any time such as the player's answer or time taken.

And thus lies a simple guide to one aspect of OOP. I'm sure others use it in different ways and will probably want to chip - but the ideas above can make complex programs a lot easily to manage.

In respect of your idea - you'll soon discover that if you clone a text input box - the clones make lousy clones because generally you want to be able to work with the text that has been entered and 'technically' this is not possible. Try it - create a single text input box with a variable and then clone it once and see what happens.

The solution is the 'copy' IE use getselection to extract the data from the input boxes and store it elsewhere - hence OOP.

Enjoy,

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: January 8th, 2009, 10:28 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
Wow, wow wow. :P

Thx Mack. That is very timely for me. That may be just what I was looking for, and grappling with.

I really appreciate the time you are taking here, and the way you've stepped through it. I expect others will find this extremely useful and reference it in the future.

I haven't digested it yet, so I may come back with questions after I try applying some of this. Currently I was/I am laying out Tables for database to store both 'object references' and values. My intent is to have the DB populate page content, hence user choices will 'drive' the pub... and I gain flexibility.

I particularly like what you've 'painted' above as the event history, as I wanted to capture some Page 'states' for bookmarking and returning/reloading.

thx again.

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


Top
 Profile  
 
 Post subject:
PostPosted: April 3rd, 2009, 9:21 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
from thread on GetPersistentObject() command: viewtopic.php?t=3573 Mack wrote:
Quote:
Any native object would need to be stored in a global variable, but of course you only need one variable to hold the super object which then holds the sub objects which then holds the properties.

I am wondering if the following instructional article properly outlines implementing this super-object? (syntax differences aside). Would appreciate a comment/sanity check if you have the time.

http://www.devshed.com/index2.php?optio ... &hide_js=1 is 'print format'
same page in standard format/main site.: http://www.devshed.com/c/a/MySQL/Dynami ... ing-OOP/2/


BTW, with the work I've done using Olaf's SQLite starter scripts... I already have Records_Array[] that contains rows of data pulled from the DB. And I've started to map standard Opus variables to DB Columns for Inserting/Updating records. So now I'm trying to figure out how to better structure this handling of sets of Opus data... ie, "objectify" into supersets. I presume it is a matter of adding 'dot properties' to same or similar Arrays?

TiA,
Larry[i].exploring

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


Top
 Profile  
 
 Post subject:
PostPosted: April 4th, 2009, 11:53 am 
Offline
Godlike
Godlike
User avatar

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

Firstly, let me clarify that I'm using the term super-object rather loosely and more as a ordinal as to were an object falls within a hierarchy.

Technically, OpusScript already has a super object, aptly named by some genius somewhere Object (mind the capital). From this all other objects stem using inheritance.

PHPs $POST and Opus' new Database are good examples of using OOP to manage data structures. As for using the idea in the example you posted, this seems perfectly feasible with OS and would save constructing all the different SQL statements but it would need to be a seizable project to make it worth the effort for something that complex or, probably more along your lines, if you were writing a set of generic functions that would work with any SQLite database regardless of structure.

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: April 4th, 2009, 10:02 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:
it would need to be a seizable project to make it worth the effort for something that complex or, probably more along your lines, if you were writing a set of generic functions that would work with any SQLite database regardless of structure.

'No', I am not going to write it to be totally universal. As you might remember in the SQLite test .imp I emailed you some time ago, I used Opus to read the DB structure and populate cascading Listboxes. That worked quite well and went 'far enough'. Although I might look at where OOPs could make such things cleaner as it were.

Quote:
Technically, OpusScript already has a super object, aptly named by some genius somewhere Object (mind the capital). From this all other objects stem using inheritance.

I think this is the pivotal point that is confusing me when I read-up on scripting or OOPs in '~parallel universes' (actionscript, JS...). :wink:
I come across something about creating a Class, and then do not see that directly in OpusScript. So I just skip over that concept and move on to the .properties. I guess it is the 'new Object()' you mention here, and just not written out with any curly brackets to bound that construct(or)(ing).

Again, thanks Mack for your earlier posts here and detailed explanation. That is becoming a reference doc as I piece this work together. 'The work' for example I used to have the Inserted Variable in a TextObject, but now am turning toward doing much much more populating content with ReplaceSelection()... and am just beginning to understand the 'shift' in emphasis or approach that implies (regarding getting content out from the DB to the Page).

Hey, put 'sooper-OOPs' on your list of videocasts someday. Thx.

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


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

All times are UTC [ DST ]


Who is online

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