Getting a list of keywords

Post

Posted
Rating:
#1 (In Topic #930)
Avatar
Trainee
I would like to print  a list of all keywords, and according to the docs there is this function :

Code (gambas)

  1. System.Keywords (gb.eval)

However, not sure how to use it. I guess I need to declare an array and write a loop, but all my attempts thus far have generated errors. Could someone kindly point me in the right direction?

Thanks!
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
Hello,
you can use FOR…EACH…NEXT cycle:

Code (gambas)

  1. Public Sub Main()
  2.  
  3.  
  4.   For Each s In System.Keywords
  5.     Print s
  6.   Next
  7.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Trainee
 Thanks vuott,

I haven't quite got my head around how the Gambas object system works and was using the wrong syntax. I've always avoided OO languages until now and have only a hazy grasp of how OOP works, and all languages seem to implement it slightly differently.
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Trainee
 Thanks for the links. I have started reading Gerry's book which is very good (thanks Gerry!), but I would prefer something more systematic. A Beginner's Guide to Gambas by John Rittinghouse is more comprehensive but it's pretty old. Anyone read it? I don't want to have to unlearn anything and there's a review on Amazon which says it's useless because it's mostly about version 2. Are newer versions of Gambas generally backwards compatible with older versions?
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’

Median Joe said

Thanks vuott,

I haven't quite got my head around how the Gambas object system works and was using the wrong syntax. I've always avoided OO languages until now and have only a hazy grasp of how OOP works, and all languages seem to implement it slightly differently.

OOP rocks :)

you can do the same print out like this..

Code (gambas)

  1. Print System.Keywords.Sort().Join("\n")
  2.  

System.Keywords returns a String[] array so i use Sort() on that
Sort returns a sorted String[] array so i use Join("\n") on that to join the items with a newline so a single string.

Note: Keywords is a "property" and Sort() and Join() are functions so no brackets needed for Keywords but needed for Sort() and Join()

After typing a Keyword/function()/method()/property/etc then pressing the dot . the autocomplete shows all the properties/methods available.

This has been pretty much all the documentation I ever needed.  I find it's kind of "learn as you go"
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Trainee

BruceSteers said

OOP rocks :)

All criticism of OOP (and there is a lot of it) seems to revolve around knowing when it's a appropriate to use it. It's a good fit for GUI, but maybe not other applications, like merging files or doing calculations for example. At least Gambas doesn't force OOP on you in all situations, as Java seems to.

Yes the built-in documentation is very good.
Online now: No Back to the top
1 guest and 0 members have just viewed this.