Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

API HELP

Status
Not open for further replies.

compcad

Programmer
Mar 22, 2002
52
0
0
US
i have designed a print program that i have found that it now needs to be called by an API that is found on another program. it is to call some paramiters from my program such as PASSWORD AND RAFFLEID what do i need to do to get this to work. here is the code used to call my program:
at this time just for RAFFLEID AND PASSWORD.
code follows:____________________________

Sub ParseCommandLine(CmdLine, RaffleID, Password,
FirstTicketNo,
LastTicketNo)
' There will be either 3 or 4 parameters
' If there are only 3 then the third is last
ticket no and a first
ticket no of 1 is implied
' If there are 4 then the third is first ticket no
and the fourth is
last ticket no
' The first 2 args are always password and
RaffleID

Password = GetNextArgument(CmdLine)
RaffleID = GetNextArgument(CmdLine)
FirstTicketNo = GetNextArgument(CmdLine)
LastTicketNo = GetNextArgument(CmdLine)

If LastTicketNo = "" Then
LastTicketNo = FirstTicketNo
FirstTicketNo = 1
End If

End Sub
Function GetNextArgument(CmdLine)

Index = InStr(CmdLine, " ")
If (Index = 0) Then
'End of line
GetNextArgument = CmdLine
GetNextArgument = Replace(CmdLine, """", "")
'Remove double
quotes
CmdLine = ""
Exit Function
End If
GetNextArgument = Left(CmdLine, Index)
GetNextArgument = Replace(GetNextArgument, """",
"") 'Remove double
quotes
CmdLine = Right(CmdLine, Len(CmdLine) - Index)
End Function

end Code___________________________
 
You may want to investigate the Split() function.

You use it like this

Code:
Private Sub Form_Load()
On Error Goto MyErrorTrap
Dim MyArray() as String  
MyArray = Split(Command,"¥")[COLOR=green]'I use the ¥ because it is not a standard keyboard character[/color]

Password = GetNextArgument(MyArray(0))
RaffleID = GetNextArgument(MyArray(1))
FirstTicketNo = GetNextArgument(MyArray(2))[COLOR=green]'if there is no value thi will raise an error 9[/color]
LastTicketNo = GetNextArgument(MyArray(3))[COLOR=green]'if there is no value thi will raise an error 9[/color]

Exit Sub
MyErrorTrap:
If Err.Number = 9 then
     Resume Next
End if
End Sub

On your command line you pass it like this
MyApp.exe MyFirstValue¥MySecondValue¥MyThirdValue¥MyForthValue

"Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top