Page 1 of 1
Posted: Thu May 02, 2002 1:35 pm
by BackupUser
Restored from previous forum. Originally posted by VeKem.
Hi,
coming from PowerBASIC and meeting PureBasic now, I'm wondering we can't set arrays as parameters to procedures. Maybe this will be possible in 3.x, Fred?
Until this, can I set for example a pointer to the first element of an array and accessing its data inside a procedure. Has PureBasic an array-descriptor (espacially intersting for string arrays)? How are Arrays managed from PureBasic?
Thanks for any help and informations!
Markus Vedder-Kemnitzer
Markus Vedder-Kemnitzer, Germany
Registered PureBasic-User
Arrays as parameters for procedures
Posted: Thu May 02, 2002 7:07 pm
by BackupUser
Code updated for 5.20+
Restored from previous forum. Originally posted by tinman.
Code: Select all
Structure wptr
w.w[0]
EndStructure
If OpenConsole()
Dim foo.w(5)
*ptr.wptr = @foo(0)
For i = 0 To 4
foo(i) = i * 3
PrintN(Str(*ptr\w[i]))
Next
Print("Press >RETURN< to end...")
Input()
EndIf
Sorry Tinman, wrong Manipulation..
Edited by - fred on 02 May 2002 23:10:29
Posted: Thu May 02, 2002 9:35 pm
by BackupUser
Restored from previous forum. Originally posted by VeKem.
Hi tinman,
thanks for your tip!
...but your code ends in V3.0 with a windows GPF while accessing *ptr\w
.

Markus Vedder-Kemnitzer, Germany
Registered PureBasic-User
Posted: Thu May 02, 2002 10:09 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
Enable the debugger and you will see the error..
Fred - AlphaSND
Posted: Thu May 02, 2002 10:48 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Sorry Tinman, wrong Manipulation..
What does that mean? And why did you edit my message?
This works fine (I should not have been so lazy with the first example), and I use this trick in a lot of other places without any problems (it has been tested on Win95, Win98 and WinXP).
Code: Select all
Structure wptr
w.w[0]
EndStructure
Dim foo.w(5)
*ptr.wptr = @foo(0)
If OpenConsole()
For i=0 To 4
foo(i)=i*3
PrintN(Str(*ptr\w[i]))
Next
Input()
CloseConsole()
EndIf
End
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
Posted: Fri May 03, 2002 5:04 am
by BackupUser
Restored from previous forum. Originally posted by VeKem.
tinman,
>What does that mean? And why did you edit my message?
>Sorry Tinman, wrong Manipulation..
>Edited by - fred on 02 May 2002 23:10:29
Fred was here...
Fred,
thanks, sorry, until now I didn't use the console and looked not in the right way to the debugger window - oh, oh, programmers....
Thanks to both for your help!
Markus Vedder-Kemnitzer, Germany
Registered PureBasic-User
Posted: Fri May 03, 2002 11:53 am
by BackupUser
Restored from previous forum. Originally posted by fred.
Sorry Tinman, wrong Manipulation..
What does that mean? And why did you edit my message?
Code: Select all
I've edited your message to copy/paste the code correctty and test it.. And I replied directly in your window by mistake. So I've overriden your text (and no way to go back).
Fred - AlphaSND
Posted: Fri May 03, 2002 1:45 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
I've edited your message to copy/paste the code correctty and test it.. And I replied directly in your window by mistake. So I've overriden your text (and no way to go back).
Ah, OK. No problem. I've posted a (hopefully) working version now anyway
--
It's not minimalist - I'm increasing efficiency by reducing input effort.