Messages - Gerome [ switch to compact view ]

Pages: prev1 ... 19 20 21 22 23 [24] 25 26 27 28 29 ... 31next
116
Developer's Corner / FBSL - Xml snippet database
« on: February 11, 2006, 06:46 AM »
Hello,

I've made a simple GUI interface that is able to load an XML database.
It is oriented to hold snippets script code.

Here's a capture of the project :


And now the source code :
' ---------------------------------------------
' XML data base reader by Gerome GUILLEMIN
' Cool XML DOM documentation can be found there :
' http://www.devguru.com/Technologies/xmldom/quickref/xmldom_index.html
' ---------------------------------------------
$Apptype GUI
#Option Explicit
ComWarnings(False)
'$Trace On

Dim %obj, %cnodes, %wdrange, $S1, %i, %j, %k, $strerr, %NodeList, %numNodes, %bLoad, %bLastEntity
Dim %TopWin, %leftWin, %RightWin, %BottomWin, %NodeListCount, $fp, %mb

LoadLibrary("Riched20.dll")
Macro CRichEdit( Caption, hWnd, ID, X, Y, Height, Width ) = FBSL_Control (_
         "richedit20a", hWnd, Caption, ID, X, Y, Height, Width,_
         WS_CHILD + WS_CLIPSIBLINGS + WS_VISIBLE + WS_HSCROLL + WS_VSCROLL + ES_MULTILINE + _
         ES_AUTOVSCROLL + ES_AUTOHSCROLL + WS_TABSTOP + ES_WANTRETURN , WS_EX_CLIENTEDGE )

Macro CInput( Caption, hWnd, ID, X, Y, Height, Width ) = FBSL_Control (_
         "edit", hWnd, Caption, ID, X, Y, Height, Width,_
         WS_CHILD + WS_CLIPSIBLINGS + WS_VISIBLE + WS_TABSTOP + ES_LEFT + ES_AUTOHSCROLL + ES_MULTILINE, WS_EX_CLIENTEDGE )

'// Label
Macro CLabel( Caption, hWnd, ID, X, Y, Height, Width ) = FBSL_Control (_
"static", hWnd, Caption, ID, X, Y, Height, Width,_
WS_CHILD + SS_NOTIFY + SS_CENTER + WS_VISIBLE, WS_EX_CLIENTEDGE )

FBSL_SetText(Me, "FBSL XML database")
ReSize(Me, 0, 0, 640, 480)
Center(Me)

Begin Enum
IDB_OPEN = 1000
IDB_PREV
IDB_NEXT
IDB_LBL
IDB_XML
IDB_RICH
End Enum

Begin Const
OUTFILE  = ".\_MySamplesNEW.xml"
    hEdit    = CRichEdit( "", Me, IDB_RICH, 0, 0, 800, 600 )
hStatus  = FBSL_Control("MSCtls_StatusBar32", Me, "", 0, 0, 0, 0, 0, 0, 0)
BUT = 60
CARTOUCH = "XML Files(*.xml)|*.xml"
hBtn1    = FBSL_Control("Button", Me, "&Open", IDB_OPEN, 10, 20, BUT, 20, WS_Child + WS_Visible + WS_TabStop, 0)
hBtn2    = FBSL_Control("Button", Me, "<<", IDB_PREV, 10+BUT*1, 20, BUT, 20, WS_Child + WS_Visible + WS_TabStop, 0)
hBtn3    = FBSL_Control("Button", Me, ">>", IDB_NEXT, 10+BUT*2, 20, BUT, 20, WS_Child + WS_Visible + WS_TabStop, 0)
hBtn4    = FBSL_Control("Button", Me, "&New XML DB", IDB_XML, 10+BUT*8+60, 20, BUT+20, 20, WS_Child + WS_Visible + WS_TabStop, 0)
hLbl1 = CLabel( "Nothing loaded yet...", Me, IDB_LBL, 10+BUT*3+10, 20, BUT+BUT, 20 )
End Const
FBSL_SetFont(hEdit, "Arial", 10, FW_BOLD, 0 ,0 ,0)
EnableWindow( hBtn3, False )
EnableWindow( hBtn2, False )

k = 1: bLastEntity = -1
GoSub ResizeMe
Show(Me)

Begin Events
Select Case CBMsg

Case WM_Close
Gosub MYReleaseObjects
GoSub WriteLastEntity
Exitprogram(0)

Case WM_Command
Select Case CBCTL
Case IDB_OPEN
GoSub LoadXml
If bLoad = True Then GoSub ClickPrevious
Case IDB_PREV
If bLoad = True Then GoSub ClickPrevious
Case IDB_NEXT
If bLoad = True Then GoSub ClickNext
Case IDB_XML
fp = FileLoad( FBSL_GetFileName( "Open", _
"FBSL Files(*.fbs)|*.fbs|Text Files(*.txt)|*.txt|CSV Files(*.csv)|*.csv|All Files(*.*)|*.*", 0 ) )
GoSub FillingXmlDB
End Select

Case WM_Size
GoSub ResizeMe

End Select
End Events

:ClickPrevious
If obj <> 0 Then
If k > 1 Then k = k - 1
If k = 1 Then
EnableWindow( hBtn2, False )
EnableWindow( hBtn3, True )
End If
GoSub GetNodeListCount
GoSub GetNodeListItem
End If
Fbsl_SetText( hLbl1, $k & "/" & $NodeListCount & " entries" )
Return

:ClickNext
If obj <> 0 Then
If k < NodeListCount Then k = k + 1
If k = NodeListCount Then
EnableWindow( hBtn3, False )
EnableWindow( hBtn2, True )
End If
GoSub GetNodeListCount
GoSub GetNodeListItem
End If
Fbsl_SetText( hLbl1, $k & "/" & $NodeListCount & " entry" )
Return

:LoadXml
k = 1: bLoad = False
If obj <> 0 Then GoSub MYReleaseObjects
obj = CreateObject("Microsoft.XMLDOM")
PutValue(obj, ".async(%b)", False)
PutValue( obj, "ValidateOnParse = %b", True )
If StrLen(FBSL_GetFileName( "Open", CARTOUCH, 0 )) > 0 Then
CallMethod( obj, ".Load(%s)", FBSL_GetFileName )
If GetValue( "%d", obj, ".parseError.errorCode" ) <> 0 then
strerr = "Error at line : " & GetValue( "%d", obj, ".parseError.line" ) & _
GetValue( "%s", obj, ".parseError.srcText" )
Msgbox( Null, strerr, "XML ERROR!", MB_OK + MB_ICONSTOP )
Else
bLoad = True
End If
End If
Return

:GetNodeListCount
If NodeList <> 0 Then ReleaseObject(NodeList)
Set NodeList = GetValue( "%o", obj, ".getElementsByTagName(%s)", "Sample")
NodeListCount = GetValue( "%d", NodeList, ".Length" )
If NodeListCount = 0 Then
MsgBox( Me, "Error : bad XML file format !", "Error", MB_ICONWARNING + MB_APPLMODAL )
GoSub MYReleaseObjects
End If
Return

:GetNodeListItem
Fbsl_SetText( hEdit, GetValue( "%s", NodeList, ".item(%d).text", k-1 ) )
Return

:MYReleaseObjects
ReleaseObject(NodeList)
ReleaseObject(obj)
ReleaseObject(cnodes)
Return

:ResizeMe
GetClientRect(Me, TopWin, leftWin, RightWin, BottomWin )
Resize( hEdit, 10, 50, RightWin - 25, BottomWin - 100 )
Resize( hStatus, 10, 10, RightWin-25, 0)
Return

:FillingXmlDB
If Strlen(fp) > 0 Then
fp = Replace( fp, "&", "&amp;" ): fp = Replace( fp, "<", "&lt;" )
fp = Replace( fp, ">", "&gt;" ) : fp = Replace( fp, " ", " " )
mb = MsgBox( Null, "Click NO to just add this sample" & _
Crlf & "Click YES to add this sample and to complete the XML database", _
"Adding ending tag or not...", MB_YESNOCANCEL + MB_APPLMODAL + MB_ICONWARNING + MB_DEFBUTTON2 )
If mb = IDCANCEL Then Return
FileOpen( OUTFILE, Append )
If FileLen(OUTFILE) = 0 Then
FilePrint( FileOpen, "<?xml version=""1.0"" encoding=""ISO-8859-1""?>")
FilePrint( FileOpen, "<Fbsl_Samples>" & CrLf & Tab & "<Content>" )
End If
If Asc(fp{StrLen(fp)}) = 10 Then
If Asc(fp{0}) = 10 Or Asc(fp{0}) = 13 Then
FilePrint( FileOpen, Tab & Tab & "<Sample>" & fp & Tab & Tab & "</Sample>" )
Else
FilePrint( FileOpen, Tab & Tab & "<Sample>" & CrLf & fp & Tab & Tab & "</Sample>" )
End if
Else
If Asc(fp{0}) = 10 Or Asc(fp{0}) = 13 Then
FilePrint( FileOpen, Tab & Tab & "<Sample>" & fp & CrLf & Tab & Tab & "</Sample>" )
Else
FilePrint( FileOpen, Tab & Tab & "<Sample>" & CrLf & fp & CrLf & Tab & Tab & "</Sample>" )
End If
End If
bLastEntity = 0
If mb = IDYES Then
bLastEntity = 1
FilePrint( FileOpen, Tab & "</Content>" & CrLf & "</Fbsl_Samples>")
End if
FileClose(FileOpen)
End If
Return

:WriteLastEntity
If bLastEntity = 0 Then
FileOpen( OUTFILE, Append )
FilePrint( FileOpen, Tab & "</Content>" & CrLf & "</Fbsl_Samples>")
FileClose(FileOpen)
End If
Return

117
Developer's Corner / FBSL - Icon viewer
« on: February 11, 2006, 06:32 AM »
[modified source to avoid crash]
Hello,

Here's a icon viewer developped in Fbsl.


The source code will show you how to :
-use volatile CLASS
-use API calls
-use API structure manipulation

'======================================================
' Shell32 Icon Index FBSL
'======================================================
#Option Explicit
#DLLDECLARE user32("GetSystemMetrics","DestroyIcon")
#DLLDECLARE comctl32("ImageList_Create","ImageList_ReplaceIcon")
#DLLDECLARE shell32("ExtractIcon")
DIM $LV_ITEM, %hList, %t, %hIcon, %hImage, $index, %j

' ------------------------------------------------------
'// SysListView Class :: TYPE + MACRO
' ------------------------------------------------------
Class SLV '// volatile class (== without parens() )
    Macro SetValue(param1, param2) = SetMem( LV_ITEM, param1, param2 )
    Static mask  = 0, iItem = 4, iSubItem = 8, state = 12
    Static stateMask = 16, pszText = 20, cchTextMax = 24, iImage = 28
    Static ILC_COLOR32 = 32, ILC_MASK = 1, LVSIL_SMALL = 1, LVSIL_STATE = 2
    Static LVS_LIST = 0x0003, LVIF_TEXT = 1, LVIF_IMAGE = 2, LVS_REPORT = 0x0001
    Static LVS_TYPEMASK = 3, LVS_EX_GRIDLINES = 1, LVS_EX_LABELTIP = 0x00004000
    Static LVIS_STATEIMAGEMASK = 0xF000, SM_CXICON = 11, SM_CYICON = 12
End Class

' ------------------------------------------------------
' // Main Entry point
' ------------------------------------------------------
Sub Main()
    MYCreateSysListView()
    Begin Events
    End Events
End Sub

' ------------------------------------------------------
'// ListView Creation
' ------------------------------------------------------
Sub MYCreateSysListView()
    Fbsl_settext(me,"Shell32 Icon Index")
    Alloc(LV_ITEM,36)

    SLV->SetValue( SLV->LVIF_TEXT + SLV->LVIS_STATEIMAGEMASK + SLV->LVIF_IMAGE, SLV->mask )' set state masks
    SLV->SetValue( 256, SLV->cchTextMax)

    hList = Fbsl_control("SysListView32",me,"",0,0,0,500,294,_
            WS_VISIBLE + WS_CHILD + SLV->LVS_LIST + SLV->LVS_TYPEMASK + SLV->LVS_REPORT, WS_EX_STATICEDGE)

    SendMessage(hList, SLV->LVM_SETBKCOLOR, 0, rgb(255,255,192))
    SendMessage(hList, SLV->LVM_SETTEXTBKCOLOR, 0, rgb(255,255,192))
    SendMessage(hList, SLV->LVM_SETEXTENDEDLISTVIEWSTYLE,0, SLV->LVS_EX_LABELTIP)

    '==========create an image list======================
    hImage = ImageList_Create(GetSystemMetrics(SLV->SM_CXICON),_
             GetSystemMetrics(SLV->SM_CYICON), SLV->ILC_COLOR32 + SLV->ILC_MASK, 1, 1)

    '====Extract the icon then destroy the handle to replace with next icon
    For t = 0 To 237
        hIcon = ExtractIcon(0,"shell32.dll",t)
        ImageList_ReplaceIcon(hImage,-1,hIcon)
        DestroyIcon(hIcon)
        If hIcon <> 0 Then j = t
    Next

    '=====set the image list to the listview=========
    SendMessage(hList,SLV->LVM_SETIMAGELIST,SLV->LVSIL_SMALL,hImage)

    '=====populate the listview======================
    For t = 0 To j
        index = "Icon # : " & t
        SLV->SetValue( t, SLV->iItem) ' item index
        SLV->SetValue( @index, SLV->pszText) ' pointer to text string
        SLV->SetValue( t, SLV->iImage) ' image index
        SendMessage(hList,SLV->LVM_INSERTITEM,0,LV_ITEM)
    Next
    Resize(me, 0, 0, 520, 324)
    Center(me)
    Show(me)
End Sub

Enjoy ;)

118
Hello,

I am not defying FBSL, in fact I know very little about it.  I glanced briefly at the "home page" of it which is just a forum and did not have the time to dig very deeply into it.  From what little I know, it seems to have a fairly small following and thus I doubt if anyone here, aside from Gerome himself of course, would be able to code this app using FBSL.  It also seems to be a high-level language similar to VBscript, which leads me to believe it might be slower than compiled C code as well.  I would be more than happy to be proven wrong of course!

Hehe...
No defy please :)
FBSL is 5 years old, and is capable of manipulating :
-1- 5 variables types : 32bits integers, 32bits floats, 64bits doubles, strings and pointers.
-2- has several native layers : COM, API, CLIPBOARD, STRING, MATHS, REGEX, COLLECTIONS, MMF, LZO COMPRESSION, SOCKETS, THREADS and CONSOLE.
-3- is able to 'self compile' into an EXEcutable that is 100% autonomous ( no extra runtime to run the code)
-4- is able to 'self decompile' an EXE into an .fbs script file/buffer
-5- has a 3rd part Stdcall flat model DLL to make C, VB, Delphi developpers using this dll to use some FBSL code through their applications.
-6- a 500 pages CHM help file that comes with grammar documentation + samples, several tutorials, macro files, declare files, constants files and more!

Compared to VBScript & JScript, FBSL is 20x faster than those scripting languages.
Compared to VBScript & JScript, FBSL is capable of beeing compiled as autonaumous EXEcutables.
Compared to VBScript & JScript, FBSL is able to call API functions from ANY kinda DLL ( C,C++,Delphi,.NET,... )
Compared to VBScript & JScript, FBSL is capable of executing VBS & JS :)
Compared to VBScript & JScript, FBSL is capable of GUI.
Compared to VBScript & JScript, FBSL is capable of Callbacks.
Compared to VBScript & JScript, FBSL is capable of natively Compressing Data.
Compared to C compiled code, FBSL is about 10% slower.
But FBSL remains a script language, onto its category, FBSL is placed amongst the fastest scripting languages :)

Yes my site is focused onto Fbsl forum, BUT don't forget that FBSL is a language, so i can guess a forum is more oriented to my language than to our personal lifes :)

At last, i'm not here to decorate, not making vaporware/deadware like tons of'em one can easily find over the internet... and amongst'em tons of started projects...

BTW, if you need help, i ust can invite you to my Forum, it's free and open minded ;)

Have a good day!

PS : to reply to the question, YES, FBSL is capable of treating the kinda GUI software you want to have...

119
General Software Discussion / Re: Best Executable Compressor Programs
« on: February 10, 2006, 04:11 PM »
Hi,

I've already tested PECompact and ... it still has a big problem with DLLs !!!
The idea is nice, the compression is good, but it fails onto some DLLs.
I've experimented it several times against my DLLs and i've never had any successful results :/
The *ONLY* program i've never had any kinda failure or warning is, and still is, is UPX Executable compressor !
FYI, my Fbsl runtimes are UPX'ed :)

120
Hi,

:tellme: Sorry, I reread you post, and it's removing duplicats you want. Are the file names accurate enough to be used to distinguish the files, or should the size/date/CRC be checked, too?

Skrommel

The deal should be not very hard to resolve since Microsoft provides COM methods to its favourite player!
The following link will expose one of the branch to manipulate a WMP playlist :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/playernewplaylist.asp
There are other ones, but if you're familiar with VB/VBA or any other language that is able to CreateObject ( so does Fbsl ;) ), then you'll be able to succed in your initial will  8)

Pages: prev1 ... 19 20 21 22 23 [24] 25 26 27 28 29 ... 31next
Go to full version