Skip to main content
guest
Join | Help | Sign In
Liberty BASIC Community Wiki Home
guest| Join | Help | Sign In
Liberty BASIC Community Wiki
  • Wiki Home
  • Recent Changes
  • Pages and Files
  • Members
  • Home
    • Liberty BASIC FAQ
    • Contests
    • Tutorials
    • Science
    • Shared Code
    • Tips
    • DLLs
    • PublicDomainSprites
    • Member Pages
    • Links
    • Sandbox

Get command line arguments

Edit 0 3 …
  • 0 Tags
    • No tags
  • Notify
  • RSS
  • Backlinks
  • Source
  • Print
  • Export (PDF)
Older Version Newer Version

bshipps64 bshipps64 Feb 17, 2006 - "First created."

=GetCommandLineArgs$ sub= An example of using the Windows API to retrieve the entire command line, then parsing that line to extract just the arguments passed to the executable. Ex: > If cmdLine$ contains "C:\test.exe /switch", then args$ will be assigned the value "/switch" > If cmdLine$ contains ""C:\test foler\test.exe" /someSwitch /anotherSwitch", > args$ will be assigned "/someSwitch /anotherSwitch" [[code format="vbnet"]] sub GetCommandLineArgs$ byref args$ q$ = chr$(34) 'API call returns pointer to a string 'containing command line contents calldll #kernel32, "GetCommandLineA",_ pointer as ulong 'Use winstring() to actually get the string 'from pointer cmdLine$ = trim$(winstring(pointer)) cLen = len(cmdLine$) 'Extract just the arguments from the variable if (left$(cmdLine$, 1) = q$) then qPos = instr(cmdLine$, q$, 2) args$ = trim$(right$(cmdLine$, cLen - qPos)) else pLen = len(word$(cmdLine$,1)) args$ = trim$(right$(cmdLine$, cLen - pLen)) end if end sub [[code]]
Help · About · Pricing · Privacy · Terms · Support · Upgrade
Contributions to https://basic.wikispaces.com/ are licensed under a Creative Commons Attribution Share-Alike 2.5 License. Creative Commons Attribution Share-Alike 2.5 License
Portions not contributed by visitors are Copyright 2018 Tangient LLC
TES: The largest network of teachers in the world
Turn off "Getting Started"
  1. Home
  2. ...
Loading...