I have two buttons on a dialog
button 1 says Check for available IP's
button 2 says Import new records
So I only see the Check for available IP's, if the function comes back with 1 show the import button and hide the check button, if the function comes back with 0, the import button never get's shown. This is what I have
function CheckAvailableAddresses as c (e as p)
dim error as L=.f.
dim error_msg as C=""
dim available_ip_addresses as N=0
'debug(1)
'run code to load available ip addresses
dim cn as sql::Connection
dim args as SQL::Arguments
dim totalavail as N =0
dim labrequested as C= e.dataSubmitted.ddLocation
dim ip_addresses_requested as N=convert_type(e.dataSubmitted.txtNumberRequested,"N")
args.Set("whichLabDoYouWant",labrequested)
flag = cn.open("::name::LE")
if flag = .T.
dim sqlCommand as c
sqlCommand = "select count(IPaddress) as totalIP from AddressTable where lablocation = :whichLabDoYouWant and IsAvailable = 1 and IpAddress like '10.%'"
if cn.Execute(sqlCommand,args) then
totalavail = cn.ResultSet.data("totalIP")
if ip_addresses_requested>0 then
if totalavail<ip_addresses_requested then
error=.t.
error_msg="Not enough IP addresses: Only "+totalavail+" available"
end if
else
error=.t.
error_msg="Invalid Amount Requested: "+ip_addresses_requested
end if
else
error_msg="Failed to load IP Addresses: "+cn.CallResult.NativeText+" | "+cn.CallResult.Text
end if
if totalavail>ip_addresses_requested then
' return 1
else
return 0
end if
end if
end function
So my question is how do I return 1 or 0
thanks
button 1 says Check for available IP's
button 2 says Import new records
So I only see the Check for available IP's, if the function comes back with 1 show the import button and hide the check button, if the function comes back with 0, the import button never get's shown. This is what I have
function CheckAvailableAddresses as c (e as p)
dim error as L=.f.
dim error_msg as C=""
dim available_ip_addresses as N=0
'debug(1)
'run code to load available ip addresses
dim cn as sql::Connection
dim args as SQL::Arguments
dim totalavail as N =0
dim labrequested as C= e.dataSubmitted.ddLocation
dim ip_addresses_requested as N=convert_type(e.dataSubmitted.txtNumberRequested,"N")
args.Set("whichLabDoYouWant",labrequested)
flag = cn.open("::name::LE")
if flag = .T.
dim sqlCommand as c
sqlCommand = "select count(IPaddress) as totalIP from AddressTable where lablocation = :whichLabDoYouWant and IsAvailable = 1 and IpAddress like '10.%'"
if cn.Execute(sqlCommand,args) then
totalavail = cn.ResultSet.data("totalIP")
if ip_addresses_requested>0 then
if totalavail<ip_addresses_requested then
error=.t.
error_msg="Not enough IP addresses: Only "+totalavail+" available"
end if
else
error=.t.
error_msg="Invalid Amount Requested: "+ip_addresses_requested
end if
else
error_msg="Failed to load IP Addresses: "+cn.CallResult.NativeText+" | "+cn.CallResult.Text
end if
if totalavail>ip_addresses_requested then
' return 1
else
return 0
end if
end if
end function
So my question is how do I return 1 or 0
thanks
Comment