Latest UploadsKing SalmonPakzSnookerJayenkaiYou've ... o have youJayenkaiMerry XmasJayenkaiRCT Classic on iOSJayenkaiOopsJayenkai

### array Problem

UserMessage
Posted : Saturday, 07 January 2012, 19:06 | Permalink
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? Function INS\$(E\$[10]) For J=1 To 6:For S=1 To Len(E\$[J]) If Mid\$(E\$[J],S,1)="B" Or Mid\$(E\$[J],S,1)="b" Mid\$(E\$[J],S,1)="/" EndIf Next Next End Function Dim R\$[10] For K=1 To 6:W=Rand(10,30): For TT= 1 To W:Q=Rand(26)+64 R\$[K]=R\$[K]+Chr\$(Q) Next Next For O=1 To 6 Print R\$[O]:Print INS\$(R\$[O]) Next --> -----DNA
Posted : Sunday, 08 January 2012, 12:00 | Permalink
bram32

WW Entries : 1
 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)
Posted : Sunday, 08 January 2012, 20:54 | Permalink
dna

 A type mismatch now Function INS(E\$[10]) Local J:Local S For J=1 To 6:For S=1 To Len(E\$[J]) If Mid\$(E\$[J],S,1)="B" Or Mid\$(E\$[J],S,1)="b" E\$[J]=Mid\$(E\$[J],1,S-1)+"/"+Mid\$(E\$[J],S+1) EndIf Next Next End Function Local R\$[10] ;Local K For K=1 To 6:W=Rand(10,30): For TT= 1 To W:Q=Rand(26)+64 R\$[K]=R\$[K]+Chr\$(Q) Next Next For O=1 To 6 Print R\$[O]:;Print INS\$(R\$[O]) Next --> The dim does not work. Does Blitz pass string arrays? -----DNA
Posted : Monday, 09 January 2012, 16:04 | Permalink
Evil Roy Ferguson

WW Entries : 3
 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: Function INS(E\$[10]) Local J:Local S For J=1 To 6:For S=1 To Len(E[J]) If Mid\$(E[J],S,1)="B" Or Mid\$(E[J],S,1)="b" E[J]=Mid\$(E[J],1,S-1)+"/"+Mid\$(E[J],S+1) EndIf Next Next End Function Local R\$[10] ;Local K For K=1 To 6:W=Rand(10,30): For TT= 1 To W:Q=Rand(26)+64 R[K]=R[K]+Chr(Q) Next Next For O=1 To 6 Print R[O]:;Print INS\$(R[O]) Next --> No idea what you're doing, though...
Posted : Monday, 09 January 2012, 19:15 | Permalink
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
Posted : Monday, 09 January 2012, 22:13 | Permalink
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. Const Max = 5 Type StringArray Field s\$[Max] End Type Function Dump(t.StringArray) For i = 1 To Max Print t\s[i] Next End Function o.StringArray = New StringArray o\s[1] = "one" o\s[2] = "two" o\s[3] = "three" o\s[4] = "four" o\s[5] = "five" Dump(o) -->
Posted : Tuesday, 10 January 2012, 19:27 | Permalink
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
Posted : Tuesday, 10 January 2012, 20:05 | Permalink
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.
Posted : Tuesday, 10 January 2012, 20:53 | Permalink
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
Posted : Tuesday, 10 January 2012, 21:05 | Permalink
Evil Roy Ferguson

WW Entries : 3
 Passing in the array works; the line doing it was just commented out in your example above and I did not change it back.
Posted : Tuesday, 10 January 2012, 21:31 | Permalink
dna

 I removed the comment and the string array did not pass. I got a Variable type mismatch error.-----DNA
Posted : Tuesday, 10 January 2012, 22:42 | Permalink
Evil Roy Ferguson

WW Entries : 3
 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.
Posted : Wednesday, 11 January 2012, 21:52 | Permalink
dna

 Found my syntax error Graphics 800,600,0,2 SeedRnd MilliSecs() Local INFO\$[16] INFO[1]="JBBBBL" For XX=2 To 10:Q=Rand(15,40) For X2= 1 To Q INFO[XX]=INFO[XX]+Chr(Rand(26)+64) Next Next For xx=1 To 16:Print INFO[XX]:Next CHECK(INFO) Function CHECK(E\$[16]) For X=1 To 10: For Y1=1 To Len(E[X]) If Mid\$(E[X],Y1,1)="B" E[X]=Left\$(E[X],Y1-1)+"*"+Mid\$(E[X],Y1+1) EndIf Next Print e[X] Next End Function WaitKey:End --> This is right.-----DNA
Posted : Thursday, 12 January 2012, 02:36 | Permalink
Retro

 Can't you just use the Replace\$ function? Function CHECK(E\$[16]) For X = 1 To 16 E[X] = Replace(E[X],"B","*") Print E[X] Next End Function -->
Posted : Thursday, 12 January 2012, 11:54 | Permalink
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
Posted : Thursday, 12 January 2012, 17:13 | Permalink
Retro

 Unlikely. The library functions would be C/C++ not BlitzBasic.
Posted : Thursday, 12 January 2012, 19:02 | Permalink
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
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 549|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
 Latest PostsHurricane Doris vs Shed Roof steve_ancell Wed 20:23 PIP Crap Jayenkai Wed 16:45 What Have You Done? - Feb 2017 rockford Wed 12:23 SSL Options Jayenkai Wed 11:31 AGameAWeek : 2017 - Part One Jayenkai Mon 08:35 Nintendo Switch Indies rychan Mon 02:48 UWP Languages rskgames Sun 05:05 Switchmas rockford Sun 04:24 Happy Birthday, Mrs Rockford rockford Fri 05:30 Pokemon Go Jayenkai Fri 04:46 More

 Latest Items Snippet : Wall Tracing on Random Maps (rpg)Pakz Wed 18:56 Blog : mini projectJayenkai Tue 06:23 Snippet : Path FollowingPakz Mon 16:25 Dev-Diary : PS2 to N64 Adapterspinal Mon 01:53 Snippet : Flowers (Jan 2017)Kuron Thu 01:13 Showcase : Clusters of Hextherevillsgames Mon 15:01 Article : Maths 101 - Episode 1: Basic Trigonometryshroom_monk Sun 14:07 Article : Maths 101 - Episode 5: Line Intersectionshroom_monk Sun 14:02 Dev-Diary : Normals and Dot productsPakz Sat 20:37 Pets : Molly On The CouchJayenkai Thu 04:32 Showcase : Between SpacePakz Sun 12:55 Snippet : Additive Particle FlamesPakz Fri 18:12 Snippet : Maze 2d - Recursive BacktrackerPakz Sun 07:34 Snippet : Bush fire mapsPakz Wed 09:43 Woot : My MusicJayenkai Sat 14:20More

Who's Online
steve_ancell
Wed, at 20:27
rskgames
Wed, at 20:21
Pakz
Wed, at 19:43
Jayenkai
Wed, at 18:27