News:

  • August 20, 2026, 10:18:24 AM

Login with username, password and session length

Author Topic: REFWRITE for a string  (Read 18636 times)

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
REFWRITE for a string
« on: August 25, 2016, 05:13:03 PM »
I need the equivalent of a REFWRITE, but I need to use it for strings.
Can this functionality be added? Or am I missing an instruction that will do it for me?
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: REFWRITE for a string
« Reply #1 on: August 26, 2016, 06:36:47 AM »
Currently, no.  One possible work around would be to set up a bunch of BYTE data blocks, then use STRGET/STRPUT whenever you needed the data in string form.

Are all your string block strings the same Max Length?

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: REFWRITE for a string
« Reply #2 on: August 26, 2016, 09:34:30 AM »
Are all your string block strings the same Max Length?
Yes, they are all the same.

I ended up just making one large string block and then using STRPRINT with my index. Now I use index 0-99 for 1, 100-199 for 2, 200-299 for 3, etc.
The REFPRINT instruction would be great though!!! ;D
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: REFWRITE for a string
« Reply #3 on: August 26, 2016, 12:39:12 PM »
Or just n-D arrays.  Most REFWRITE cases would be addressed if we had multiple dimension arrays, I believe.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: REFWRITE for a string
« Reply #4 on: August 26, 2016, 01:47:06 PM »
Multidimensional arrays would be great! I cannot remember where the thread was where we talked about it... Are there going to be multidimensional arrays in DMD 2.0?
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: REFWRITE for a string
« Reply #5 on: August 26, 2016, 01:51:38 PM »
I think the current word is not initially, but hopefully eventually.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: REFWRITE for a string
« Reply #6 on: August 27, 2016, 12:03:08 PM »
Multidimensional arrays would be great! I cannot remember where the thread was where we talked about it... Are there going to be multidimensional arrays in DMD 2.0?

No. Not too hard to manage though, now that MATH boxes support expressions in the output parameter. If you had a two dimensional array that was ROWS x COLUMNS, with V0 being the first dimension index and V1 being the second, the read and write syntax is simply aMyArray[V0*ROWS + V1]. Yes, it's limited to a MATH box, but it's only marginally harder to code than aMyArray[V0][V1].
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: REFWRITE for a string
« Reply #7 on: August 27, 2016, 01:39:02 PM »
That's a decent solution, but not completely, exactly analogous because it's wangling a one-dimensional array into behaving [somewhat] like a 2D.  Accessing one cell at a time, there are a lot of viable solutions

But...the primary reason I want N-D arrays has to do with accessing multiple elements in one shot, where solutions like this one fall down.  For example, I might use a bit array MyBitArray[0..256][0..5000], because I want there to be a syntax that lets me WRITE all the bits in MyBitArray[52][243...789], but I'm READING the array orthogonal to the way I'm writing: MyBitArray[][2157] should return some structure containing 256 bits.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: REFWRITE for a string
« Reply #8 on: August 27, 2016, 02:08:49 PM »
That's a decent solution, but not completely, exactly analogous because it's wangling a one-dimensional array into behaving [somewhat] like a 2D.  Accessing one cell at a time, there are a lot of viable solutions

But...the primary reason I want N-D arrays has to do with accessing multiple elements in one shot, where solutions like this one fall down.  For example, I might use a bit array MyBitArray[0..256][0..5000], because I want there to be a syntax that lets me WRITE all the bits in MyBitArray[52][243...789], but I'm READING the array orthogonal to the way I'm writing: MyBitArray[][2157] should return some structure containing 256 bits.

That is pretty much exactly the way C implements arrays under the covers, because all memory is a one dimensional array. There is exactly a 0% chance of multi-dimensional arrays being implemented in Do-more until we do a major overhaul of some critical internal constructs, which very likely happens when we do a future class of processor in which we want to greatly expand memory capacities, but not until then. In the meantime, if your goal is to index memory using two or more indices, the solution I offered is not bad.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: REFWRITE for a string
« Reply #9 on: August 27, 2016, 02:29:12 PM »
That is pretty much exactly the way C implements arrays under the covers, because all memory is a one dimensional array.

Granted -- so I guess the distinction I'm making would be syntax that treats all the dimensions interchangeably.  IOW, "under the covers" is good!  Normally, like you guys, I favor the Better Toolbox over the Finished Coffee Table paradigm, but in this case I'd value a good layer of abstraction.

Quote
There is exactly a 0% chance of multi-dimensional arrays being implemented in Do-more until we do a major overhaul of some critical internal constructs, which very likely happens when we do a future class of processor in which we want to greatly expand memory capacities, but not until then.

Looking forward to it!   :)
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: REFWRITE for a string
« Reply #10 on: November 16, 2017, 07:31:51 PM »
Kicking this can again to keep it alive.  To recap -- the reason I want a formal N-d syntax is to stripe across the array along an arbitrary selection of axis or axes.

You're quite right that reading or writing one cell at a time using that workaround is quite viable, as are others, but if that's all you do, why would you need an N-d array in the first place?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.