HOW-TO : Build a Simple GUI = Lesson 1 - Praparing Script
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

HOW-TO : Build a Simple GUI = Lesson 1 - Praparing Script

Started by ??????Hawk??????, 23 August, 2004, 23:15:36

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

??????Hawk??????

Heya peeps...


I am by no means a pro at this but thaught id share what i know in here for everyone to see.
so if any one else wants to chip in with comments or more efficient ways then feel free
and maby i can learn something aswell..

Here we will create a Simple GUI for one of my scripts.
i am using ' Visual Basic 6 Pro ' so if you can pls d/l and install the same.


ok  heres the script we will be working with

Click Here To Download in full with supporting .txt files

unzip to your scripts directory.


Main Code.
--------------------------------------------------------


--====================================================
--=================Clock Settings=====================

BotName = "Ascii-Clock"
TimeZone = "GmT" 		-- Set time zone i.e   gmt+1 , gmt+2 , gmt-1 , gmt-2   etc.  etc.
ClockInterval = 1   		-- Displays Ascii Clock every # mins in main chat
HubAddy = "*******  blahh.no-ip.com  ********" 	--Hub Addy to display in clock
HubName = "*****   my hub   *******"	--Hub Name to display in clock
commandprefix = "+"

---- commands ------

--   !time  -- display ascci clock in main chat
--   !ver   -- display clock ver


function Main() 
DefineVariables()
	SetTimer(mins)
	StartTimer() 
end 


function OnTimer()
	ClockTimer()
end



function DataArrival(user, data)
	if( strsub(data, 1, 1) == "<" ) then
		local s,e,prefix,cmd = strfind(data, "%b<>%s+(%S+)(%S+)") 
			if prefix == commandprefix.."time" then
				parceTime()
				TimeToAll(fileh,fileh1,filem,filem1)
			elseif prefix == commandprefix.."clockver" then
 				user:SendData( Version_info )
			end
	end
end  

--------------------------------------------------------


function parceTime()
cdate = date("%x")
hoursa = date("%H")
minsa = date("%M")
hours = tonumber(hoursa)
mins = tonumber(minsa)
	if hours < 10 then
		fileh = "0.txt"
		fileh1 = hours..".txt"

	elseif hours < 20 then
		firstpm = hours - 10
		fileh = "1.txt"
		fileh1 = firstpm..".txt"
	elseif hours < 25 then
		firstpm = hours - 20
		fileh = "2.txt"
		fileh1 = firstpm..".txt"
	end

	if mins < 10 then
		filem = "0.txt"
		filem1 = mins..".txt"
	elseif mins < 20 then
		firstpm = mins - 10
		filem = "1.txt"
		filem1 = firstpm..".txt"
	elseif mins < 30 then
		firstpm = mins - 20
		filem = "2.txt"
		filem1 = firstpm..".txt"
	elseif mins < 40 then
		firstpm = mins - 30
		filem = "3.txt"
		filem1 = firstpm..".txt"
	elseif mins < 50 then
		firstpm = mins - 40
		filem = "4.txt"
		filem1 = firstpm..".txt"
	elseif mins < 60 then
		firstpm = mins - 50
		filem = "5.txt"
		filem1 = firstpm..".txt"
	elseif mins  == 60 then
		firstpm = mins - 60
		filem = "6.txt"
		filem1 = firstpm..".txt"
	end
return fileh,fileh1,filem,filem1
end

function TimeToAll(fileh,fileh1,filem,filem1)
filec = "10.txt"
Tempclockfile = "\r\n\r\n       ***********************************************\r\n" 
Tempclockfile = Tempclockfile..""..HubName.."\r\n" 
Tempclockfile = Tempclockfile.."       ******************"..cdate.."******************" 
 local handle = openfile("asciiclock/"..fileh, "r") 
	if (handle ~= nil) then 
		local line = read(handle) 
		local line = "              "..line
		local handle1 = openfile("asciiclock/"..fileh1, "r") 
		local line = line..""..read(handle1) 
		local handle2 = openfile("asciiclock/"..filec, "r") 
		local line = line..""..read(handle2) 
		local handle3 = openfile("asciiclock/"..filem, "r") 
		local line = line..""..read(handle3) 
		local handle4 = openfile("asciiclock/"..filem1, "r") 
		local line = line..""..read(handle4) 

			while line do 
				Tempclockfile = Tempclockfile.."\r\n"..line
				line = read(handle) 
					if (line ~= nil) then 
						line = "              "..line
						line = line..""..read(handle1)
						line = line..""..read(handle2)
						line = line..""..read(handle3)
						line = line..""..read(handle4)
					end 
			end 
		Tempclockfile = Tempclockfile.."\r\n       ****************** "..TimeZone.." ***********************\r\n" 
		Tempclockfile = Tempclockfile..""..HubAddy.."\r\n" 
		Tempclockfile = Tempclockfile.."       ************************************************\r\n" 
		SendToAll(BotName, Tempclockfile) 
		closefile(handle) 
		closefile(handle1) 
		closefile(handle2) 
		closefile(handle3) 
		closefile(handle4) 
	end 
end

--------------------------------------------------------------------------------


--------------------------------------------------------


function ClockTimer()

		parceTime()
		TimeToAll(fileh,fileh1,filem,filem1)
end



--------------------------------------------------------


function DefineVariables()

Version_info = "\r\n\t\tAscii clock Ver 1.01 By ??????Hawk??????"
mins = 1000 * 60 * ClockInterval
current = date("%H:%M:%S")
end




Ok first off we need to Prepare the script to read its settings from an External file.

open Note Pad and ' CUT ' and paste this code from the script in to it......

TimeZone = "GmT"
ClockInterval = 1
HubAddy = "*******  blahh.no-ip.com  ********"
HubName = "*****   my hub   *******"
commandprefix = "+"

notice ive removed all comments from it aswell there not needed

save the file AS  Settings.cfg in to your Scripts directory.

now you need to add a line of Code to the main Script to read the Settings.cfg file

Add this line to the ' function DefineVariables() ' part of the script

assert(dofile("Settings.cfg"),"settings file error")

your scripts directory should now contain:-

[asciiclock]          <-- folder
AsciiClockv1.01.lua   <-- Main Script
Settings.cfg          <-- New config file

the main script should look like this

--====================================================
--=================Clock Settings=====================


---- commands ------

--   !time  -- display ascci clock in main chat
--   !ver   -- display clock ver


function Main() 
DefineVariables()
	SetTimer(mins)
	StartTimer() 
end 


function OnTimer()
	ClockTimer()
end



function DataArrival(user, data)
	if( strsub(data, 1, 1) == "<" ) then
		local s,e,prefix,cmd = strfind(data, "%b<>%s+(%S+)(%S+)") 
			if prefix == commandprefix.."time" then
				parceTime()
				TimeToAll(fileh,fileh1,filem,filem1)
			elseif prefix == commandprefix.."clockver" then
 				user:SendData( Version_info )
			end
	end
end  

--------------------------------------------------------


function parceTime()
cdate = date("%x")
hoursa = date("%H")
minsa = date("%M")
hours = tonumber(hoursa)
mins = tonumber(minsa)
	if hours < 10 then
		fileh = "0.txt"
		fileh1 = hours..".txt"

	elseif hours < 20 then
		firstpm = hours - 10
		fileh = "1.txt"
		fileh1 = firstpm..".txt"
	elseif hours < 25 then
		firstpm = hours - 20
		fileh = "2.txt"
		fileh1 = firstpm..".txt"
	end

	if mins < 10 then
		filem = "0.txt"
		filem1 = mins..".txt"
	elseif mins < 20 then
		firstpm = mins - 10
		filem = "1.txt"
		filem1 = firstpm..".txt"
	elseif mins < 30 then
		firstpm = mins - 20
		filem = "2.txt"
		filem1 = firstpm..".txt"
	elseif mins < 40 then
		firstpm = mins - 30
		filem = "3.txt"
		filem1 = firstpm..".txt"
	elseif mins < 50 then
		firstpm = mins - 40
		filem = "4.txt"
		filem1 = firstpm..".txt"
	elseif mins < 60 then
		firstpm = mins - 50
		filem = "5.txt"
		filem1 = firstpm..".txt"
	elseif mins  == 60 then
		firstpm = mins - 60
		filem = "6.txt"
		filem1 = firstpm..".txt"
	end
return fileh,fileh1,filem,filem1
end

function TimeToAll(fileh,fileh1,filem,filem1)
filec = "10.txt"
Tempclockfile = "\r\n\r\n       ***********************************************\r\n" 
Tempclockfile = Tempclockfile..""..HubName.."\r\n" 
Tempclockfile = Tempclockfile.."       ******************"..cdate.."******************" 
 local handle = openfile("asciiclock/"..fileh, "r") 
	if (handle ~= nil) then 
		local line = read(handle) 
		local line = "              "..line
		local handle1 = openfile("asciiclock/"..fileh1, "r") 
		local line = line..""..read(handle1) 
		local handle2 = openfile("asciiclock/"..filec, "r") 
		local line = line..""..read(handle2) 
		local handle3 = openfile("asciiclock/"..filem, "r") 
		local line = line..""..read(handle3) 
		local handle4 = openfile("asciiclock/"..filem1, "r") 
		local line = line..""..read(handle4) 

			while line do 
				Tempclockfile = Tempclockfile.."\r\n"..line
				line = read(handle) 
					if (line ~= nil) then 
						line = "              "..line
						line = line..""..read(handle1)
						line = line..""..read(handle2)
						line = line..""..read(handle3)
						line = line..""..read(handle4)
					end 
			end 
		Tempclockfile = Tempclockfile.."\r\n       ****************** "..TimeZone.." ***********************\r\n" 
		Tempclockfile = Tempclockfile..""..HubAddy.."\r\n" 
		Tempclockfile = Tempclockfile.."       ************************************************\r\n" 
		SendToAll(BotName, Tempclockfile) 
		closefile(handle) 
		closefile(handle1) 
		closefile(handle2) 
		closefile(handle3) 
		closefile(handle4) 
	end 
end

--------------------------------------------------------------------------------


--------------------------------------------------------


function ClockTimer()

		parceTime()
		TimeToAll(fileh,fileh1,filem,filem1)
end



--------------------------------------------------------


function DefineVariables()
assert(dofile("Settings.cfg"),"settings file error")
Version_info = "\r\n\t\tAscii clock Ver 1.01 By ??????Hawk??????"
mins = 1000 * 60 * ClockInterval
current = date("%H:%M:%S")
end


And it should run ok ...


ok ill leave you all to d/l and install VB6......

Back Soon With More......................

nErBoS

Hi,

The GUI of my script is now avaible, hope it can help you guys one making your own. My code isn?t the best, i have learned C++ one year ago, but its a help.

Is made in C++ and programmed in Borland Builder C++.

Download HERE

Best regards, nErBoS
--## nErBoS Spot ##--

SMF spam blocked by CleanTalk