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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Arrays as parameters for procedures
Code updated for 5.20+
Restored from previous forum. Originally posted by tinman.
Sorry Tinman, wrong Manipulation..
Edited by - fred on 02 May 2002 23:10:29
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
Edited by - fred on 02 May 2002 23:10:29
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
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).
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
What does that mean? And why did you edit my message?Sorry Tinman, wrong Manipulation..
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.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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
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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
What does that mean? And why did you edit my message?Sorry Tinman, wrong Manipulation..
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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
Ah, OK. No problem. I've posted a (hopefully) working version now anywayI'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).

--
It's not minimalist - I'm increasing efficiency by reducing input effort.