Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / The meaning of subscript

Author
Message
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 12th Mar 2011 13:02 Edited at: 12th Mar 2011 14:08
Hi, im a bit confused as to the meaning of subscript in the context this book that i am reading is using.
Subscript to me means the smaller letters that you get in capitals when you type using the subscript option on. In chemical formulas it means something i simply do not understand. But i have found no help for it in regards to programming yet my book keeps on referencing it.

What does this mean?

A stacks array index variable can be set to the top of the stack (the subscript of the right-most cell) using the array index to stack statement.

Other examples are:

The array index can be made to reference the last cell (the cell with the highest subscript) using the array index to bottom statement.

I dont understand these statements as it is so throwing a word i do not know in there is making it more confusing im afraid (does it just mean whatever number is stored in that element?)

Somebody please help because i am really struggling with arrays and what the hell i need all these commands for (for example why 'Add to stack' is exactly the same effect as 'Add to queue', what do we need both for?) and words that i cant work out are not really helping.

Many thanks in advance.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Mar 2011 13:37 Edited at: 12th Mar 2011 13:38
Subscript = index as you've already used it.

ADD TO STACK and ADD TO QUEUE do indeed have exactly the same effect on an array, but REMOVE FROM STACK and REMOVE FROM QUEUE don't. But how strange would it be to have an ADD TO STACK with a corresponding REMOVE FROM QUEUE? And that's the answer - consistency.

BTW, the difference between REMOVE FROM STACK and REMOVE FROM QUEUE isn't just that they remove different items from the array. Each array has a hidden index/subscript value that can be used with stacks, queues or lists. REMOVE FROM STACK sets that index to the last item in the array while REMOVE FROM QUEUE sets it to the first item.

Here's some explanatory pieces of code for stacks, queues and lists.

There are also some extras that I added to the array plug-in in my collection that makes using the hidden index easier to use - GET ARRAY INDEX and SET ARRAY INDEX.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 12th Mar 2011 14:05 Edited at: 12th Mar 2011 14:09
Thanks Ian, i had a guess at why add to stack/queue were the same and i thought it might be consistancy, i just threw in the example as i was geting a little confused at the whole thing

So a subscript is the index of an array thats already been set up?
So like Example(10) would create an array called example with 11 elements and:
Example(2) = 4 would put the value 4 into the element 2 of the array (all simple stuff that ive already covered)

So:
4 Would then be that subscript? Is this right?

Edit: Re-reading that a couple of times i now think perhaps the subscript is the index. So actually the subscript is 2 i think.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Mar 2011 14:55 Edited at: 12th Mar 2011 14:56
That's right - they are two ways of saying the same thing, and yes your index/subscript is 2.

Just to make the terminology 100% clear:

Array(Index) = Value

Index is also known as subscript (which if not specified in DBPro, the hidden index is used instead), 'Array(Index)' is an element of the array 'Array', and Value can be a simple scalar value or a UDT.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 12th Mar 2011 15:21
Thanks for clearing that up Ian. I know to a lot of people that may have seemed obvious therefore making this dumb noob question of the day but ive been reading so much just lately that it tripped me up and i wanted to make sure i knew whats what before moving on.

Thanks.

Login to post a reply

Server time is: 2024-11-22 23:48:53
Your offset time is: 2024-11-22 23:48:53