Hypercard conversion issue

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Alistair
Posts: 33
Joined: Mon Jun 23, 2008 6:45 am
Location: Victoria University

Hypercard conversion issue

Post by Alistair » Sun Oct 12, 2008 2:55 am

Here is a rather unusual Hypercard conversion issue.

I am working on converting a card that displays a trace. Values need to be shown along an axis. The tricky part is that the values vary depending on the trace. In Hypercard, the values were added as the trace was drawn. This was easy because text could be put directly on the card. Simply putting the text in a text field doesn't work because a separate text field must be provided for each point on the axis. The calculation of each value involves many lines of code. Once calculated, the value then needs to be sent to the correct text field. I can think of a number of ways to script this but none is particularly simple or elegant. The positions of the labels are fixed. Has anyone a suggestion for a simple way of scripting insertion of the values in the appropriate fields?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Sun Oct 12, 2008 11:06 am

there's several ways, and it highly depends on your existing code. For example, if the markers on the axis have a name, then you could name the fields that way.

Another elegant, but less simple approach would be to not name the fields something usable, but marking them with an identifier. for example: "field 1", "field 2", "field 3", ... Then you'd collect an array with the content being the names of all the field, and the keys an identifier that your code predetermines:
key, content
dinosaur died out, field 2
neandertaler, field 3
ice age, field 4
modern age, field 5
...

Or if your code works better the other way, you could reverse the array, having the keys being the fields names.

If your problem lies more with the association of the field with the actuall x,y position on the card, then you could name the fields "position 288" according to the point on your axis.

If you need to know only the sequence of fields, but not the actual place, then you could use this string "field 1,field 2,field 3,field 4,...". Then you loop over each item: repeat for each item in allTheFields

There's many more ways you can make your code know the fields, but it highly depends on the way your code works.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Alistair
Posts: 33
Joined: Mon Jun 23, 2008 6:45 am
Location: Victoria University

Post by Alistair » Sun Oct 12, 2008 12:57 pm

The markers don't have a name. All that is displayed is a numerical value but the values depend on the trace. The use of a two-dimensional array might be the way to go, with the calculated values first being put into the array and then being transferred to the respective fields via a loop once the array is filled. At the moment, the values are calculated as the trace is produced. In the Hypercard version each value was displayed as it was calculated.

Post Reply

Return to “Mac OS”