123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|426|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> array Problem

Sat, 07 Jan 2012, 19:06
dna

Hey.

I'm trying to pass an array into a function and change certain characters within the string.

This code is giving me an error. Is it the square bracket?



-=-=-
DNA
Sun, 08 Jan 2012, 12:00
bram32
Hey dna,
I think it is the assignment to Mid$ that doesn't work:

Mid$(E$[J],S,1)="/"

Should be something like:
E$[J] = Left$(E$[j],S-1) + "/" + Mid$(E$[j],S+1)
Sun, 08 Jan 2012, 20:54
dna
A type mismatch now



The dim does not work.

Does Blitz pass string arrays?


-=-=-
DNA
Mon, 09 Jan 2012, 16:04
Evil Roy Ferguso
Blitz's array support is anemic. You can pass string arrays to methods, but the so called "blitzarrays" break if you specify the type anywhere but declaration. That is to say, the following will work:



No idea what you're doing, though...
Mon, 09 Jan 2012, 19:15
dna
Thanks Evil One

Still, It compiles but does not pass the array.

Must be some funny syntax.

the program will replace any occurrence of Upper or Lower case B with a "/".

From there it will do something else.

I might be able to get the result using integers instead of passing the string to the function. Just compare the integer to the "/" equivalent.

-=-=-
DNA
Mon, 09 Jan 2012, 22:13
Retro
I'm no Blitz expert, so apologies if this is utter crap.

It seems to me you could wrap the string array in a custom type.
This would be passed by reference, e.g.


Tue, 10 Jan 2012, 19:27
dna
That probably is the best method (no pun) for doing what I'm attempting.

I did want to know the square bracket string array syntax though.

-=-=-
DNA
Tue, 10 Jan 2012, 20:05
Retro
I guess if you use that method, you may as well not use an array at all.
i.e. just use the built-in type iterators. They're stored in a linked-list, so effectively you'd have a dynamic array.
Tue, 10 Jan 2012, 20:53
dna
You are right again but the algorithm was created to test the use of passing those square bracket arrays.

It's undocumented in some versions of BB

I'll learn types then.

-=-=-
DNA
Tue, 10 Jan 2012, 21:05
Evil Roy Ferguso
Passing in the array works; the line doing it was just commented out in your example above and I did not change it back.
Tue, 10 Jan 2012, 21:31
dna
I removed the comment and the string array did not pass. I got a Variable type mismatch error.

-=-=-
DNA
Tue, 10 Jan 2012, 22:42
Evil Roy Ferguso
That's because you're passing in a single element of the array with INS(R[0]) instead of the array, when what you need is just INS®. You also can't print the result of that, since it doesn't return anything.
Wed, 11 Jan 2012, 21:52
dna

Found my syntax error


This is right.

-=-=-
DNA
Thu, 12 Jan 2012, 02:36
Retro
Can't you just use the Replace$ function?


Thu, 12 Jan 2012, 11:54
dna
Yes I could have.
I never knew the command existed before. That looks easier than using the mid$ function.
What I wrote is probably the same somewhere inside the REPLACE function.



-=-=-
DNA
Thu, 12 Jan 2012, 17:13
Retro
Unlikely. The library functions would be C/C++ not BlitzBasic.
Thu, 12 Jan 2012, 19:02
dna
You're right again but I meant the logistics of how it works.
thanks for pointing that out to me.
I have never really read the B3D manual.



-=-=-
DNA