Jump to content

jwurmz

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by jwurmz

  1. Thank you for making this, it helps me a lot in my project. I have run into an issue I'm hoping you can help with -- Pack($hDbf) just locks the program up. All other file operations seem to operate as needed; I can create a DBF from scratch, add records, read records, and mark records as deleted without any major issue. However, a Pack operation doesn't succeed and I need this big time. The program becomes unresponsive and requires forced closure. The record in the DBF is still there and marked as deleted. Can you recommend a way past this? Here is a sample snippet of code that does cause an unresponsive application on my side (the file does exist and has records marked for deletion): #include <dBase.au3> $hDbf = OpenDBF(@ScriptDir & "\_agents.dbf") Pack($hDbf) CloseDBF($hDbf) Also, there seems to be a limit on length of large file names and large field names. Is this by design or is there possibly something wrong on my side? OS: Win 7 Professional x64. The following snippet produces a filename "eislarge.dbf" with a single field named "thisfieldn": #include <dBase.au3> $hDbf = CreateDBF("_thisfilenameislarge.dbf", $DBASEIII) AddField($hDbf, "thisfieldnameislarge", "C", 20, 0, 0, 0) CloseDBF($hDbf) And if I can be so bold as to add a request -- if possible, ability to detect if a record has been marked as deleted would be useful. I would like to use this in conjuction with (or within) the GetSubRecord function. Or, is there some way of getting this information that I'm not seeing?
  2. I'm trying to create an application that will create an image-based signature for email. It will take as input a number of text strings like Full Name, Job Title, Phone/Fax, Company Logo (, etc.). The program would place those text strings and the logo in series, and generate an image of that series, like in the attachment. I'm trying to use GDI+ to get it done, but I'm having some trouble with saving the image -- it just saves a black image. I'm not exactly sure what I'm doing wrong; if anyone can help that would be great OR if you can suggest another way of achieving the same results that would also be great. Here is my code: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> $mainwindow = GUICreate("Signature Generator", 400, 200, (@DesktopWidth / 2) - 200, (@DesktopHeight / 2) - 200) GUISetState() $fullnamelabel = GUICtrlCreateLabel("Name:", 10, 13, 40, 20, $SS_RIGHT) $fullnameinput = GUICtrlCreateInput("", 55, 10, 165, 20) $fullnamefont = GUICtrlCreateCombo("Arial", 225, 10, 120, 20) $fullnamesize = GUICtrlCreateInput("12", 350, 10, 40, 20) $fullnamesizeupdown = GUICtrlCreateUpdown($fullnamesize) $titlelabel = GUICtrlCreateLabel("Title:", 10, 38, 40, 20, $SS_RIGHT) $titleinput = GUICtrlCreateInput("", 55, 35, 165, 20) $titlefont = GUICtrlCreateCombo("Arial", 225, 35, 120, 20) $titlesize = GUICtrlCreateInput("12", 350, 35, 40, 20) $titlesizeupdown = GUICtrlCreateUpdown($titlesize) $phonelabel = GUICtrlCreateLabel("Phone:", 10, 63, 40, 20, $SS_RIGHT) $phoneinput = GUICtrlCreateInput("", 55, 60, 165, 20) $phonefont = GUICtrlCreateCombo("Arial", 225, 60, 120, 20) $phonesize = GUICtrlCreateInput("12", 350, 60, 40, 20) $phonesizeupdown = GUICtrlCreateUpdown($phonesize) $faxlabel = GUICtrlCreateLabel("Fax:", 10, 88, 40, 20, $SS_RIGHT) $faxinput = GUICtrlCreateInput("", 55, 85, 165, 20) $faxfont = GUICtrlCreateCombo("Arial", 225, 85, 120, 20) $faxsize = GUICtrlCreateInput("12", 350, 85, 40, 20) $faxsizeupdown = GUICtrlCreateUpdown($faxsize) $logolabel = GUICtrlCreateLabel("Logo:", 10, 118, 40, 20, $SS_RIGHT) $logobutton = GUICtrlCreateButton("Browse", 55, 110, 335, 35) $savebutton = GUICtrlCreateButton("Save", 55, 150, 335, 40) $previewwindow = GUICreate("Preview", 400, 200, (@DesktopWidth / 2) - 200, (@DesktopHeight / 2) - 100 + 150, $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW, $previewwindow) $context = _WinAPI_GetWindowDC($previewwindow) _GDIPlus_Startup() $previewgraphic = _GDIPlus_GraphicsCreateFromHDC($context) $brush = _GDIPlus_BrushCreateSolid (0x7F00007F) $format = _GDIPlus_StringFormatCreate () $fontfamily = _GDIPlus_FontFamilyCreate ("Arial") $font = _GDIPlus_FontCreate ($fontfamily, 12, 2) $rectfont = _GDIPlus_RectFCreate (140, 100, 100, 20) _GDIPlus_GraphicsDrawStringEx ($previewgraphic, "Hello world", $font, $rectfont, $format, $brush) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $savebutton $tempbmp = _GDIPlus_BitmapCreateFromGraphics(400, 200, $previewgraphic) _GDIPlus_ImageSaveToFile($tempbmp, @ScriptDir & "\test.bmp") _GDIPlus_BitmapDispose($tempbmp) EndSelect WEnd _GDIPlus_FontDispose ($font) _GDIPlus_FontFamilyDispose ($fontfamily) _GDIPlus_StringFormatDispose ($format) _GDIPlus_BrushDispose ($brush) _GDIPlus_GraphicsDispose ($previewgraphic) _WinAPI_ReleaseDC($mainwindow, $context) _GDIPlus_Shutdown () GUIDelete()
  3. Actually, I found a workaround by using a couple extra StringMid steps instead -- works exactly as I expect it to now. Thank you I tried working with it in binary form and all of the sudden other areas of my program started acting funny. If you're still wanting to look at it for the sake of curiosity, I can supply the data files and the source but the logic for StringReplace has been completely removed from my code so you would have to build that part back in yourself. The problem has been sidestepped, so it's up to you. Thanks for all your help over the last week jchd, it's very much appreciated!
  4. I'm opening a file (w/ flag 16), reading the contents of a file as binary string, converting the binary string (with BinaryToString) to a 'regular' string, and trying to StringReplace a potion of it based on a start value (portion length = replacement string length, start value = predetermined offset in the file). The problem is StringReplace is returning 1 (along with 'eating' my source string) and I'm not exactly sure why. Some of the characters in the converted 'regular string' are sometimes unprintable characters; they may be any value 0-255. I guess my question is -- does StringReplace return error = 1 if it encounters any unprintable characters in the source string?
  5. Yes, somehow I missed the entire section with the diagrams. I think it was because I was under the assumption that the float I was working with was only 32 bits. Anyhow, thanks for all your help in both threads ProgAndy, I tried using your functions but no matter what value I feed into them, I get 0 returned. I don't suppose it's because I'm using Windows 7, is it? EDIT: Yep, ran it on an XP machine and it worked great. Thank you!
  6. that is exactly what I needed -- a breakdown of the MBF double structure! Thank you!!!
  7. I'm working with some old, flat database files that store information using the MBF specification (other thread). I've found a couple DLLs for converting MBF datatypes to their equivalent IEEE formats, but I've never used DllCaLL before so I'm not sure I'm doing it properly. @error is set to 1 everytime I try I'm using MBFIEE32.DLL, found here. According to the documentation: MBFIEE32.DLL MBF <-> IEEE Conversion Free Sample Functions from Stamina Copyright 1997, MicroDexterity, Inc. Free distribution encouraged, include this TXT file. For information, visit http://www.mdxi.com email: stamina@mdxi.com or call +1 313-453-5872 ----------------------- This free DLL is supplied "AS IS" -- no warranty is offered or implied. ----------------------- MBFIEE32.DLL contains 4 functions to convert floating point values between IEEE format and the older Microsoft Binary Format (MBF). It's intended to replace the older free library MBF2IEEE.DLL, which only works in 16-bit Windows. The functions are: DxToIEEEd - Converts MBF Doubles to IEEE Doubles DxToIEEEs - Converts MBF Singles to IEEE Singles DxToMBFd - Converts IEEE Doubles to MBF Doubles DxToMBFs - Converts IEEE Singles to MBF Singles These are identical to functions in Stamina, a library of more than 260 functions written in 32-bit assembly language. We offer these for free hoping it will prompt you to take a look at the other routines in Stamina. Instructions Copy MBFIEE32.DLL to your Windows\System (or System32) directory. Don't install it in an application directory. Because these functions are exposed through a typelib, you don't need to use Declares or function prototypes. Just add a reference to this library to your project. How you do that depends on what product you're using -- for VB5, the "Project... References" menu is where you begin. From there, Browse the System directory, select MBFIEE32.DLL, and you're done. The library will appear in your Object Browser, and the DLL will be entered in the registry. The conversions happen in-place... these directly affect the variable passed to them, for best speed and convenience. Just read an MBF value into an IEEE double, and invoke DxToIEEEd. The variable will be converted directly to IEEE. In VB: Get #n,, ADouble# ' ADouble is MBF in the file DxToIEEEd ADouble# ' now ADouble is in IEEE format Going the other way: DxToMBFs ASingle! ' IEEE ASingle is converted to MBF Put #n,, ASingle! ' Store in the file as MBF For fields in a User-Defined Type, just point these routines at the element of interest: Type FileRecType LongElement As Long DoubleElement As Double ... End Type Dim FileRec as FileRecType Get #n,, FileRec DxToIEEEd FileRec.DoubleElement ...so if I wanted to convert an MBF double to its IEEE equivalent I thought the correct syntax for the call would be: $myMBFdouble = StringMid($currentrecord, 23, 8) ;"0xD0CCCCCCCCCC1084" $myIEEEdouble = DllCall("MBFIEE32.DLL", "double", "DxToIEEEd", "double", $myMBFdouble) ;I also tried "str", etc. ...but as I mentioned, @error = 1 every time. Any thoughts?
  8. Yes, they are definitely floating-point numbers. Unfortunately, they are also definitely stored using only 32 bits. It would not appear as though QB7.1 conforms to IEEE-754; that, or these datatypes are being operated on 'manually' in the code and stored using the programmer's own format. I still have access to the original app, so I'm going to poke at the numbers for a while until I get it figured out. Thanks for your help! EDIT: I see what's going on now. Actually there were 2 things that threw me off: 1) I have 2 floats that are stored per record in my data file, 1 as a 64-bit double and 1 as a 32-bit single. I was only testing using the 32-bit field, oops! 2) http://support.microsoft.com/kb/140520 -- it turns out they aren't using IEEE, but MBF instead. I should be good to go. Thanks again!
  9. I have some 32bit numbers stored in a particular format (used in a QBASIC 7.1 program) and I can't seem to figure out how to display them properly after reading them in using FileRead (FileOpened with "0" flag). Here's an example: 0x99996183, displayed in the QBASIC7.1 app as "7.05" Can anyone provide suggestion on how to convert/format these raw 32bit numbers into their readable, decimal counterpart?
  10. As it turns out, there was one extra byte (0x00) in the NR record. I just changed the reading of this field to 29 bytes instead of 30 and it works great. Thanks again!
  11. Yeah, I am sure that I'm finding the file correctly. I only posted one of the invoices files that are in my specified directory -- there are actually hundreds of them, all with data that works fine in another app. I just used "1" as the index because it was quicker to see the results than if I was parsing all files. I know exactly what you mean about array indices, they've gotten me a million times before. What leads me to believe it's not an index issue is because the $customerreference by itself worked fine. I'm not ruling anything out at this point, though. I was thinking it may have been due to non-readable characters so I told it to strip the whitespace using flag 3 (all whitespace before AND after string); this seemed to yield the same results. I can't test any of your suggestions for a couple of hours. I will certainly let you know how it goes. Thank you very much for your help!!!
  12. I appreciate the offer, but I don't see a way to PM files. It looks like I still have room in my global quota here... DATFILES.zip
  13. I'm working on a script which reads data records from an old flat-file DOS database. It parses all records in the file and populates a combobox using a string made from one or more of the fields from each record. Everything works fine when I'm using a string built using a single field from each record separated by "|". My problem seems to be caused when I try to add a combobox item using a string built out of the second text field, $customername. Everything is fine if I just use the $customerref field; the combobox gets an item added for each record in the dat file. If I try it with just the $customername field (or any combination that includes it) it will only add a single item to the combbox. It does not produce an error or anything, just stops after the first entry. Here's the code, in it's sloppy entirety: #include <GuiConstantsEx.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> ;;Variable declarations/definitions ;MsgBox(4096, @ScriptDir, @ScriptDir) ;$dosdirectory = @ScriptDir $dosdirectory = "C:\Santos\Datapax" ;$dosdirectory = "C:\Users\jwurmz\Desktop\SantosDATAPAX010510\DATAPAX" Dim $foundinvoicefiles[1000] Dim $foundcustomerfiles[1000] Dim $foundinvoices[1000000] Dim $foundcustomers[10001] Dim $customerrecord[255] Dim $invoicerecord[42] ;;Main GUI $maingui = GuiCreate("Datapax 6.x", 200, 100, (@DesktopWidth / 2) - 100, (@DesktopHeight / 2) - 50) $mainarbutton = GUICtrlCreateButton("Accounts Receivable", 5, 5, 190, 20) ;;AR GUI $argui = GUICreate("Datapax 6.x - Accounts Receivable", 640, 480, (@DesktopWidth / 2) - 320, (@DesktopHeight / 2) - 240, $WS_EX_TOOLWINDOW) GUICtrlCreateLabel("Customer:", 10, 10, 60, 20) $arcustomercombo = GUICtrlCreateCombo("", 60, 8, 300, 20, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL, $CBS_SORT)) $arreceiptgroup = GUICtrlCreateGroup("Add Receipt", 395, 5, 230, 75) $ardatepicker = GUICtrlCreateDate("", 410, 25, 200, 20) GUICtrlCreateLabel("Receipt Total:", 410, 50, 80, 20) $arreceipttotalinput = GUICtrlCreateInput("", 480, 48, 50, 20) $araddbutton = GUICtrlCreateButton("Add", 535, 48, 75, 20) $arlistView = GuiCtrlCreateListView("Date|Customer|BillTo|Description|PartialPay|Prompt|Amount|Status|Source|Route|Tax1|Tax2", 10, 90, 615, 325) $testaritem = GuiCtrlCreateListViewItem("100107|J420|X1014|57156|$0.00|pd455600|$475.13|*|FP|1|$0.00|$0.00", $arlistView) $arsavebutton = GUICtrlCreateButton("Save", 10, 425, 80, 20) $arabortbutton = GUICtrlCreateButton("Abort", 100, 425, 80, 20) $arabortbutton = GUICtrlCreateButton("Print Statement", 200, 425, 80, 20) $arexitbutton = GUICtrlCreateButton("Exit AR", 545, 425, 80, 20) ;;Allocation GUI $allocgui = GUICreate("Allocations", 320, 240, (@DesktopWidth / 2) - 160, (@DesktopHeight / 2) - 120, $WS_EX_TOOLWINDOW) GUICtrlCreateLabel("Test:", 10, 10, 60, 20) Func FindAllInvoiceFiles() ;;Empty array For $i = 1 to 1000 $foundinvoicefiles[$i - 1] = "" Next ;;Search DOS directory for INV files $search = FileFindFirstFile($dosdirectory & "\INV*.DAT") ;;Check if the search was successful $numfound = 0 If $search = -1 Then MsgBox(0, "Error", "No invoice files found in directory: " & $dosdirectory) ;Exit Else Do $file = FileFindNextFile($search) If @error Then ExitLoop If $file <> "" Then ;MsgBox(4096, "File:", "#" & $numfound & " - " & $file) $foundinvoicefiles[$numfound] = $file $numfound = $numfound + 1 EndIf Until $file = -1 EndIf EndFunc Func FindAllCustomerFiles() ;;Empty array For $i = 1 to 1000 $foundcustomerfiles[$i - 1] = "" Next ;;Search DOS directory for INV files $search = FileFindFirstFile($dosdirectory & "\CUSTOM*.DAT") ;;Check if the search was successful $numfound = 0 If $search = -1 Then MsgBox(0, "Error", "No customer files found in directory: " & $dosdirectory) ;Exit Else Do $file = FileFindNextFile($search) If @error Then ExitLoop If $file <> "" Then ;MsgBox(4096, "File:", "#" & $numfound & " - " & $file) $foundcustomerfiles[$numfound] = $file $numfound = $numfound + 1 EndIf Until $file = -1 EndIf EndFunc Func FindAllCustomers() $customerfile = FileOpen($dosdirectory & "\" & $foundcustomerfiles[1], 0) $numcustomerrecords = FileGetSize($dosdirectory & "\" & $foundcustomerfiles[1]) / 255 If $customerfile <> -1 Then For $i = 1 to $numcustomerrecords $record = FileRead($customerfile, 255) If $customerfile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $customername = StringLeft($record, 30);StringStripWS(StringLeft($record, 30), 3) $customerref = StringMid($record, 31, 1) $pad = "" If StringLen(String(Asc(StringMid($record, 32, 1)))) < 3 Then $padnum = 3 - StringLen(String(Asc(StringMid($record, 32, 1)))) For $j = 1 to $padnum $pad = $pad & "0" Next EndIf $customerref = $customerref & $pad & String(Asc(StringMid($record, 32, 1))) $foundcustomers[$i] = $customerref ;& StringStripWS($customername, 3) ;=================================================this routine doesn't report cust ref for nr and vi properly, or add it to the combo when customer name is included Next EndIf $arcustomercombostring = "" For $i = 1 to 10000 If $foundcustomers[$i] <> "" Then $arcustomercombostring = $arcustomercombostring & $foundcustomers[$i] & "|" EndIf Next If StringLen($arcustomercombostring) > 1 Then GUICtrlSetData($arcustomercombo, $arcustomercombostring) EndIf EndFunc GUISwitch($maingui) GuiSetState() FindAllInvoiceFiles() FindAllCustomerFiles() FindAllCustomers() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $mainarbutton GUISetState(@SW_SHOW, $argui) ;Case $msg = $testaritem ;GUISetState(@SW_SHOW, $allocgui) ;Case $msg = $argobutton ;FindAllCustomers() Case $msg = $arexitbutton GUISetState(@SW_HIDE, $argui) GUISwitch($maingui) EndSelect WEnd ...and the data files are attached to thi message. The path to the data files ($dosdirecory) is hard coded at the moment so you'll have to update it to wherever you download the DAT files. Line 100 is the beginning of where the file is read. I know for certain that the file is being read fine and that there is readable text in the 2 fields I am reading ($customername, $customerref) for all records in the file. Line 115 is where the two fields are combined into a single string and stored in an array (although in the code above it is partially commented to allow for good results using a single field). If you can offer any help it would be greatly appreciated!!! Thank you! DATfiles.7z
  14. v3.2.8.1 did you try code? i can't get a listview with more than 4095 entries...
  15. anyone know of a way to bypass the apparent limit of 4095 entries in a ListView control? CODE#include <GUIConstants.au3> GUICreate("Listview", 130, 300) $listview = GuiCtrlCreateListView("Index|Rnd", 10, 10, 120, 280) GUISetState() For $addlistitem = 1 to 10000 $listitem = "#" & $addlistitem & "|" & String(Int(Random(0, 100))) GUICtrlCreateListViewItem($listitem, $listview) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Exit
×
×
  • Create New...