Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
'create a test file
Local r,s,t,i,j,k As Long, temp$
r = 5 : s = 6 : t = 7
Kill "text.txt"
Open "text.txt" For Binary As #1
Put#1,,r
Put#1,,s
Put#1,,t
Close #1
? "Bytes written:" + Str$(SizeOf(r)+SizeOf(s)+SizeOf(t))
'read it back
Open "text.txt" For Binary As #1
temp$ = Space$(Lof(1))
Get #1,Lof(1),temp$
Close #1
? "Bytes read:" + Str$(Len(temp$))
i = Cvl(temp$,0) : ? Str$(i) '<--- does not return 5
j = Cvl(temp$,4) : ? Str$(j) '<--- does not return 6
k = Cvl(temp$,8) : ? Str$(k) '<--- does not return 7
End If
End Function
'gbs_00838
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm