Sunday, December 27, 2015

MsgBoxTimeOut function module


'//MsgBoxTimeOut module
'//Author          : s0ft
'//Contact         : aayush.babu@yahoo.com
'//Blog            : c0dew0rth.blogspot.com
'//Usage Example   : MsgBoxTimeOut "Sample msgbox content",vbOkOnly,"Title",5000,500 'timeout of 5 seconds with initial delay of 0.5 seconds
'//Compile type    : P-Code. A lot of problems with CreateThread API in Native mode
'//Date/Time       : 2015/12/27 - 10:12 PM

Option Explicit

Private Declare Function CreateThread Lib "kernel32.dll" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByRef lpParameter As Any, ByVal dwCreationFlags As Long, ByRef lpThreadId As Long) As Long
Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function TerminateThread Lib "kernel32.dll" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long

Dim strContent_ As String
Dim boxType_ As Long
Dim strTitle_ As String
Dim TimeOut_ As Long
Dim initialDelay_ As Long


Public Sub MsgBoxTimeOut(ByVal strContent As String, ByVal boxType As Long, ByVal strTitle As String, ByVal TimeOut As Long, ByVal initialDelay As Long)
strContent_ = strContent
boxType_ = boxType
strTitle_ = strTitle
TimeOut_ = TimeOut
initialDelay_ = initialDelay
Dim threadID As Long
CreateThread ByVal 0&, ByVal 0&, AddressOf step1, ByVal 0&, ByVal 0&, threadID
End Sub

Private Sub step1()
Dim threadID As Long
Dim hThread As Long
Sleep initialDelay_ '//the initial delay must be here, not inside the msgbox thread. that would be silly
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf step2, ByVal 0&, ByVal 0&, threadID)
Sleep TimeOut_
TerminateThread hThread, 0
End Sub

Private Sub step2()
MessageBox 0, strContent_, strTitle_, boxType_
End Sub

Saturday, November 28, 2015

PokemonShowdown Helper

I'm back. It's been a long time, over a year. Lot of things have happened, lot have changed in RL. But a blog has to go on.
Today, browsing through my desktop HD, I found this project that I remember I had undertaken some months back, maybe a month after the quake, so that's May. I sometimes liked to play pokemonshowdown, still do. It was fun, very fun, until it wasn't. I used to be so interested for a while and when I had got enough, I used to stop. And this, I created when I was head over heels into it. Some point down the road, I lost interest and left it. And today, there it was, lying there on my desktop. I tested to see how well and if it worked. And it did, exactly as I remember it had.
About what it is all about, it parses through your ongoing battle and displays information that may be useful to you as a player, in real time(obviously). The pokemons involved, their attacks and their speeds are what are shown. Pressing the F9 key toggles display of some basic info regarding the currently active pokemons(their base stats) loaded from a txt file. F8 toggles the main window.
Optionally, it allows the pokemons and their attacks encountered in battles to be recorded or "learn"t in a file. This I probably added to make the recorded data more usable to players in future versions. Currently, this "knowledge vault" file serves no purpose within the program.
Oh, one thing, it only works with internet explorer.

Anyway, here it is.

Monday, September 8, 2014

iSolve

This is my first android app.
I couldn't find a single app on play store to solve n-dimensional simultaneous equations which I sometimes find use for so upon learning to write code for my smartphone, I implemented Cramer's rule for the job. The main engine of this part of the program here is finding the determinant of any square matrix which is done via recursion.
The other component of iSolve is the Polynomial Solver which is an android translation of RootFinderC.
This app has some bugs but is functional.
Download iSolve

Monday, February 17, 2014

RootFinderC

A console C program to estimate the roots of given single variable equation.
Added estimation by Bisection Method.
Download

Sunday, January 26, 2014

WordMaker X

This is a new version of Word Finder. Because searching for subset words in a wordlist is so much faster than generating and checking different permutations of the seed word, the save feature has been removed with a few modifications to the interface.

Download here

Saturday, January 25, 2014

Word Finder

A program that finds out what words could be created out of a given seed word. For example: if you are given 'leghorn' as your seed word, other sub-words that can be created out of it that are of length greater than 4 are:
lore
lone
long
ergo
glen
goer
gore
gone
hero
hole
horn
hone
ogle
ogre
oner
role
noel
loner
enrol
heron
longer
Progress can be saved using the 'Stop' button into a config.inf file that will be generated upon a click.
For resuming, the config.inf file should be in the same directory as the main program executable. In this case, the 'Make words' button functions as the resume command. For the operation to begin from where it was left, the program generated config.inf file and the new-words-list text file must be present in the program's directory or else, in case of absence of config.inf the operation will begin from the start and in case of absence of the new-words-list text file, the process will resume from the last word it found out and write it in a new new-words-list file.
Download here
Note : A standard wordlist.txt file has been included in the archive.

Sunday, May 12, 2013

Simple asterisk filter function for strings

Took a bit of thinking to achieve this. This function processes a given string and tells whether it is in agreement with the provided filter input. It accepts the wildcard filter character, asterisk(*) only.
It returns TRUE if the given 'name' parameter is compatible with the provided 'filter' parameter.

Private Function FilterCompliant(ByVal name As String, ByVal filter As String) As Boolean
'//Author : s0ft
'//Contact : aayush.babu@yahoo.com
'//Blog : http://www.c0dew0rth.blogspot.com
'//Usage : Returns TRUE if the given 'name' string is compliant with the given 'filter'
'//it is crucial to understand the working of the asterisk * wildcard character to make a function that processes it
filter = LCase$(filter)
name = LCase$(name)
If filter = "*" Then
    FilterCompliant = True
    Exit Function
End If
Dim splitparts() As String
splitparts = Split(filter, "*")
If splitparts(0) = "" Then splitparts(0) = Left$(name, 1) '//if filter starts with * like e.g *gr*q then make splitparts(0) which would otherwise be "" the first letter of the name
nextstart = 1 '//tells from where to start looking for between-the-asterisk-characters in filter var
For i = 0 To UBound(splitparts)
If Left$(filter, InStr(filter, "*") - 1) = Left$(name, InStr(filter, "*") - 1) Then '//whether *sth or go*sth, the first character(s)-before-asterisk must be the same in filter and name var. So this is a necessary condition
    If InStr(nextstart, name, splitparts(i)) <> 0 Then '//search from nextstart position the string splitparts(i) in name var
        nextstart = InStr(nextstart, name, splitparts(i)) + Len(splitparts(i)) '//so that next time instr wont count the same letter
        cnt = cnt + 1
    Else
        Exit For
    End If
End If
Next i
If cnt = UBound(splitparts) + 1 Then '//necessary condition
    If Right$(filter, 1) = "*" Then '//if filter is in format:  hehe*
        FilterCompliant = True
    ElseIf StrReverse(Left$(StrReverse(filter), InStr(StrReverse(filter), "*") - 1)) = Right$(name, InStr(StrReverse(filter), "*") - 1) Then '//if input is in format: comp*r then give YES to only those words with the same after-final-asterisk-character(s)
        FilterCompliant = True
    End If
End If
End Function



Usage example:

Private Sub Form_Load()
Debug.Print FilterCompliant("eloquent", "*oq*")
End Sub