Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hmmm... naming question
#1
Code:
DIM name.length                        AS LONG
DIM name.segment.amount                AS LONG
DIM name.amount                        AS LONG
DIM name.segment.length                AS LONG
name.segment.length = 1024
name.segment.amount = (name_length - 1) \ name.segment.length + 1
name.amount = 0
DIM name.string(name.length)           AS INTEGER
DIM name.segStart(name.segment.amount) AS LONG
DIM name.segEnd(name.segment.amount)   AS LONG
DIM name.recStart(name.amount)         AS LONG
DIM name.recEnd(name.amount)           AS LONG

This is a structure for a global string in a program I am desperately trying to make. I want it to be designed for easy deletion/creation/size modificaton for each sub-string. This is not just for a global string: I intend to make this structure for a few other uses as well (INTEGER, etc).

The entire string is inside the name.string() array.
Each individual string "record" is made up of a set of string segments.
Each string segment refers to a part of the name.string() array.
Thus, to access an entire string record, this is done:

Code:
'for record 5:
record = 5
FOR i% = name.recStart(record) TO name.recEnd(record)
FOR j% = name.segStart(i%) TO name.segEnd(i%)
PRINT CHR$(name.segStart(i%));
NEXT j%, i%

Thus, it's possible to change the segment lengths and the record lengths too without redefining the entire array each time.

And, here are my names for creating and changing the size of the records:

Code:
FUNCTION create.flex.string
END FUNCTION

FUNCTION paste.flex.string
END FUNCTION

FUNCTION cut.flex.string
END FUNCTION

FUNCTION delete.flex.string
END FUNCTION

FUNCTION defrag.flex.string
END FUNCTION

I haven't figured out all the details yet, but I was just wondering whether anyone had any better naming ideas. Perhaps a naming convention for this sort of thing?
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#2
Ah, the befuddlement of reading Aga's posts...
What the hell is that?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#3
Yeah, I have absolutely no clue what he is doing...

By the way, it is really stupid that a DWORD is still 32 bits, even in 32 bit C++.
Reply
#4
Aga...if you seek approval for using "underscore" in place of "dot" in non-TYPE variables/function names...I whole-heartedly approve. :bounce: :bounce:

Now...if you learn to indent, I look forward to reading your code Big Grin

Or did I misunderstand the point of your post :???:
Reply
#5
Oh, if that is what he is doing, then I don't like it. In C++, I only use underscores to show that a variable is a member variable.

Code:
class Point{
public:
    //Some accessor functions (talk about overboard OO)
private:
    int _x;
    int _y;
}


I would say some_variable_name is worse than someVariableName.
Reply
#6
Quote:I would say some_variable_name is worse than someVariableName.

The thing is...

Aga has been arguing for the use of some.variable.name which *is* legal in QB...but utterly confusing since TYPE usage makes use of the "dot" operator to distinguish TYPE name from TYPE member...

AGA has some great ideas, but he's stubborn as an ox...becomes adament when pressed on an issue where he may have to conceed he was wrong....

examples include...

insistence that GOTO makes for "good" code
refusal to use indentation
use of multi-use lines (heavy use of coloned statements)
reckless inclusion of "dot" in variable names

Big Grin

so...I was attempting to offer encouragement to aga for what I interpreted as making an effort at reasonableness...he is, after all, a talented coder, and a pretty nice guy!!!
Reply
#7
Well........ Thanks for the support, but... Powerbasic doesn't let you use dots for array names....

I'm sorry for confusing you all.. I guess this is a bad place to put powerbasic code. :oops:

Let me rephrase my question and change it to QB...

EDIT: OK, rephrased..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#8
IMO you will have to redim the array everytime you want to change the segment and record length. Theres no other choice. Its QB!

I could try to suggest an alternative if you could just tell me what exactly are you trying to achieve?
Reply
#9
Quote:IMO you will have to redim the array everytime you want to change the segment and record length. Theres no other choice. Its QB!

I could try to suggest an alternative if you could just tell me what exactly are you trying to achieve?

Err..... that's the point of the array set: ability to change the record length quickly...

EDIT: Well I haven't implemented this yet, so naturally I forgot a few things, like:

Code:
DIM SHARED inventory.emptySegment(inventory.segment.amount) AS LONG
DIM inventory.emptySegmentLocation
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)