Just a snippit on 'ProgramParameter()'

Share your advanced PureBasic knowledge/code with the community.
HarryO
User
User
Posts: 42
Joined: Wed May 07, 2003 4:25 am
Location: Palatine,IL.,USA

Just a snippit on 'ProgramParameter()'

Post by HarryO »

Hi All,

Since everybody has been so helpfull, I thought I could make a contribution to help the other newbies to PureBasic.

Just thought this could help someone else. Nothing fancy.

Code: Select all

; Example of using the command 'ProgramParameter()'
;
;    In this example, the linklist is named 'PG_Parms'
;    The procedure to get the parameters of the
;    command is 'Get_Prog_Params()'
;
;    And the returned value, from the procedure is the 
;    number of elements (thus the number of parameters)
;    in the linklist.
;
;    App has been tested under W98SE, 800Mhz, 256Mb Memory

;    Use as you wish and as usual, 
;    NO WARRENTY IS IMPLIED OR OFFERED
;    USE AT YOUR OWN RISK!!!
;		

num_parm.w = 0
x_var.w = 0
Stuff.s = " "

Procedure.w Get_Prog_Params()
  Protected x1.w, a1.s
  a1 = Space(255)
  x1 = 0
  NewList PG_Parms.s()
  Repeat
    a1 = ProgramParameter()
    If Len(a1) > 0 
      AddElement(PG_Parms())
      PG_Parms() = a1
    EndIf
  Until Len(Trim(a1)) < 1
  x1 = CountList(PG_Parms())
  FirstElement(pg_parms())
  ProcedureReturn x1
EndProcedure

If OpenConsole()

  num_parm = get_prog_params()

  PrintN("Number of elements in the Linklist = " + Str(num_parm) + " .")
  stuff = input()
  printn(" ")
	
  if num_parm > 0
    For x_var = 1 To Num_Parm
      PrintN("Element number : " + Str(x_var) + ", in the Linklist.")
      PrintN("Element Value  : " + PG_Parms() + ", in the Linklist.")
      NextElement(pg_parms())
      printn(" ")
    Next x_var
  EndIf
  input()

EndIf

End

Hope this helps!

HarryO
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

Thank you.
It helps to have "simple" examples
to make learning easier for
my "simple" mind! :D
Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Post Reply