March 29, 2024, 07:11:49 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Pointers - How to use them

Started by Andy, December 19, 2015, 04:59:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Big thanks to Larry Mc for guiding me step by step on how to use pointers.

So I thought I would create some examples on how to use them (from a beginners point of view).

Here are eight examples on how to use INT's, STRINGS and ISTRINGS with pointers, I hope they will be of some use to you if you have never used pointers before or was just unsure.

Best wishes, as always,

Andy.
:)

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

aurelCB

good Andy
but if beginner need to understand what is pointer variable type
then i think that must start with such a simple program..
Using user guide is great help .

DEF p as POINTER 'Create a pointer called ''.
INT i=7
'reference pointer
p = i 'Tell p it is pointing to an integer i

'Get the values and print them...
openconsole
'de-reference pointer
print #p
do:until inkey$ <> ""
closeconsole

Andy

December 19, 2015, 11:52:13 PM #2 Last Edit: December 19, 2015, 11:54:02 PM by andy1966
Thanks for that,

Yes I agree with what you say, the reason for the post is that in the case of pointers the help file was not telling me (that I could find) how to write code (using pointers) with strings, istrings, UDT's and arrays (examples A3 to A7).

I also had to work out how you can increase a pointer size (example A8) without losing data.

So once you have read the help file, you can look at my examples to help you move on with poiters.

Just thought they cover all the basic questions I was asking myself, and likely someone else new to pointers would probably ask.

Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

aurelCB

hi Andy yes i agree that some things are not explained very well in user guide
also you may look in topic here on forum where i and LarryMc talk about using pointer
and linked list in ABasic.