brdga
06-26-2004, 11:12 PM
Is it possible to have an action change the coding for another action?
Here is what I am trying to do. On one page of my app i have a server listbox that is populated from an ini. The data for the listbox items is the ip address of the server. When the "ping" button is pushed it executes a batch file that pings the servers and writes the results to a text file. It then uses string actions to extract the pings of each server by finding the ip and moving to the the characters representing the ping. Then displays the ping next to the server in a paragraph block. Initially the app has a default list of servers listed in the ini and the batch. Two fields are used to add a server name and ip manually which updates the ini and batch as well as the listbox.
What I cannot for the life of me figure out is how to have the ping button look for the ip of the new server and extract the ping. I was hoping when the server was added I could use a piece of code to change the code of the ping button.
Below is the code I am using to ping the servers.
-- Clears the paragraph window
Paragraph.SetText("Paragraph1", "");
-- Runs the batch file to ping servers
File.Run("AutoPlay\\Docs\\pinger.bat", "", "AutoPlay\\Docs", SW_MINIMIZE, true);
--Reads the results to a string
serverlist = TextFile.ReadToString("AutoPlay\\Docs\\serverlist.txt");
-- Finds the last 3 digits of the ip plus a colon
ping1_loc = String.Find(serverlist, "137:", 1, false);
-- Finds the ping
ping1 = String.Mid(serverlist, ping1_loc + 19, 5);
-- An if then statement that compares two numbers
-- The Characters " Sent" appear at that location when the destination was unreachable.
if (ping1 == " Sent") then
ping1 = "?????"
end
ping2_loc = String.Find(serverlist, ".64:", 1, false);
ping2 = String.Mid(serverlist, ping2_loc + 19, 5);
-- An if ... else statement that compares two numbers
if (ping2 == " Sent") then
ping2 = "?????"
end
ping3_loc = String.Find(serverlist, ".73:", 1, false);
ping3 = String.Mid(serverlist, ping3_loc + 19, 5);
-- An if ... else statement that compares two numbers
if (ping3 == " Sent") then
ping3 = "?????"
end
-- Writes all ping values to the paragraph
Paragraph.SetText("Paragraph1", ping1 .. "\r\n" .. ping2 .. "\r\n" .. ping3);
Here is what I am trying to do. On one page of my app i have a server listbox that is populated from an ini. The data for the listbox items is the ip address of the server. When the "ping" button is pushed it executes a batch file that pings the servers and writes the results to a text file. It then uses string actions to extract the pings of each server by finding the ip and moving to the the characters representing the ping. Then displays the ping next to the server in a paragraph block. Initially the app has a default list of servers listed in the ini and the batch. Two fields are used to add a server name and ip manually which updates the ini and batch as well as the listbox.
What I cannot for the life of me figure out is how to have the ping button look for the ip of the new server and extract the ping. I was hoping when the server was added I could use a piece of code to change the code of the ping button.
Below is the code I am using to ping the servers.
-- Clears the paragraph window
Paragraph.SetText("Paragraph1", "");
-- Runs the batch file to ping servers
File.Run("AutoPlay\\Docs\\pinger.bat", "", "AutoPlay\\Docs", SW_MINIMIZE, true);
--Reads the results to a string
serverlist = TextFile.ReadToString("AutoPlay\\Docs\\serverlist.txt");
-- Finds the last 3 digits of the ip plus a colon
ping1_loc = String.Find(serverlist, "137:", 1, false);
-- Finds the ping
ping1 = String.Mid(serverlist, ping1_loc + 19, 5);
-- An if then statement that compares two numbers
-- The Characters " Sent" appear at that location when the destination was unreachable.
if (ping1 == " Sent") then
ping1 = "?????"
end
ping2_loc = String.Find(serverlist, ".64:", 1, false);
ping2 = String.Mid(serverlist, ping2_loc + 19, 5);
-- An if ... else statement that compares two numbers
if (ping2 == " Sent") then
ping2 = "?????"
end
ping3_loc = String.Find(serverlist, ".73:", 1, false);
ping3 = String.Mid(serverlist, ping3_loc + 19, 5);
-- An if ... else statement that compares two numbers
if (ping3 == " Sent") then
ping3 = "?????"
end
-- Writes all ping values to the paragraph
Paragraph.SetText("Paragraph1", ping1 .. "\r\n" .. ping2 .. "\r\n" .. ping3);