xbennY0 Posted November 2, 2014 Share Posted November 2, 2014 (edited) Is it possible to set data in a struct from a .bin file like in C? thx! example in C++: struct stAccount { stSocket Socket; short Status; char PacketBuffer[2048]; stDataBase DataBase; }; stAccount Client[5000]; void Request::Login(stAccount *n_Client) { p20D *Packet = (p20D*)&n_Client->PacketBuffer; FILE *hFile = NULL; char *TMP = new char[100]; sprintf(TMP, "DataBase\\Accounts\\%c\\%s.bin", GetFirstKey(Packet->Username), Packet->Username); SecureZeroMemory(&n_Client->DataBase, sizeof(stDataBase)); fopen_s(&hFile, TMP, "rb"); // read binary fread(&n_Client->DataBase, sizeof(stDataBase), 1, hFile); // "strcpy to struct" fclose(hFile); } Edited November 2, 2014 by xbennY0 Link to comment Share on other sites More sharing options...
Rockerfeller Posted November 2, 2014 Share Posted November 2, 2014 I don't know c well but you can populate an autoit dllstruct with the contents of a file. Give a little more info on your goal. xbennY0 1 Link to comment Share on other sites More sharing options...
xbennY0 Posted November 2, 2014 Author Share Posted November 2, 2014 (edited) For example... I have 100 folders and each of these folders have another 50 folders within, within those 5000 folders (100 folders * 50 in each one) there are 20 .txt files containing some text. Something like this: ...folder 1: - sub folder[1-1]: - data[1].txt - [...] - data[20].txt - [...] - [...] - sub folder[1-50]: - data[1].txt - [...] - data[20].txt ------------------------------------------------------------------------ ...folder 2: - sub folder[2-1]: - data[1].txt - [...] - data[20].txt - [...] - [...] - sub folder[2-50]: - data[1].txt - [...] - data[20].txt ------------------------------------------------------------------------ ...folder 3: - sub folder[3-1]: - data[1].txt - [...] - data[20].txt - [...] - [...] - sub folder[3-50]: - data[1].txt - [...] - data[20].txt ------------------------------------------------------------------------ ...[...]: ------------------------------------------------------------------------ ...folder 100: - sub folder[100-1]: - data[1].txt - [...] - data[20].txt - [...] - [...] - sub folder[100-50]: - data[1].txt - [...] - data[20].txt I need to get all this information (including the name of the folders) and put into a struct! is it possible? thanks! Edited November 2, 2014 by xbennY0 Link to comment Share on other sites More sharing options...
Danyfirex Posted November 2, 2014 Share Posted November 2, 2014 Of couse yes. _FileListToArrayRec to search the txt. and fileread+dllstructure. Saludos xbennY0 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
xbennY0 Posted November 2, 2014 Author Share Posted November 2, 2014 (edited) Of couse yes. _FileListToArrayRec to search the txt. and fileread+dllstructure. Saludos Woww!! Thx bro! then I want to save the struct in a binary file for easier reading(to not need to use the folders) can you make a simple example?? best regards. Edited November 2, 2014 by xbennY0 Link to comment Share on other sites More sharing options...
Danyfirex Posted November 2, 2014 Share Posted November 2, 2014 I think no need to use structure for that. You simple should use _FileListToArrayRec+fileread+filewrite or filecopy Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
xbennY0 Posted November 2, 2014 Author Share Posted November 2, 2014 (edited) I think no need to use structure for that. You simple should use _FileListToArrayRec+fileread+filewrite or filecopy Saludos but I want something to remove these folders! I don't want to use them... like make a binary file with everything inside, you see? Edited November 2, 2014 by xbennY0 Link to comment Share on other sites More sharing options...
Rockerfeller Posted November 3, 2014 Share Posted November 3, 2014 Do you mean like a zip file or something similar, with all the files in ? Link to comment Share on other sites More sharing options...
guinness Posted November 3, 2014 Share Posted November 3, 2014 SQL database? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
xbennY0 Posted November 3, 2014 Author Share Posted November 3, 2014 Do you mean like a zip file or something similar, with all the files in ? Yes! SQL database? How? this is a good idea? Celtic88 1 Link to comment Share on other sites More sharing options...
xbennY0 Posted November 4, 2014 Author Share Posted November 4, 2014 up Link to comment Share on other sites More sharing options...
BrewManNH Posted November 4, 2014 Share Posted November 4, 2014 There are examples of using archiving software to do what you want, do a search of the examples section for ZIP. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
xbennY0 Posted November 4, 2014 Author Share Posted November 4, 2014 There are examples of using archiving software to do what you want, do a search of the examples section for ZIP. but I do not want to work with the folders!! I want them as structs Link to comment Share on other sites More sharing options...
BrewManNH Posted November 4, 2014 Share Posted November 4, 2014 Are you sure, do you even know what a struct is? What possible use would they be to you as a struct, and what would you do with the contents of this struct once yo've deleted the folders and put them inside it? xbennY0 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
xbennY0 Posted November 4, 2014 Author Share Posted November 4, 2014 (edited) Are you sure, do you even know what a struct is? What possible use would they be to you as a struct, and what would you do with the contents of this struct once yo've deleted the folders and put them inside it? of course i know... I would save it in a .bin to read it later, exactly the example that I gave in c++ the idea is to merge everything into one file(as a binary for example) excluding the folders. Do this in c++ is easy i don't know here in autoit... thanks for your help bro! Edited November 4, 2014 by xbennY0 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2014 Moderators Share Posted November 4, 2014 xbennY0,Why not just use _FileListToArrayRec to get all of these files into an array and then loop through it reading their content, adding this content to a single text file, and then deleting them? That sounds the quickest way of doing you want. Although I would delete the files on a second pass - just in case something goes wrong. M23 xbennY0 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xbennY0 Posted November 4, 2014 Author Share Posted November 4, 2014 xbennY0, Why not just use _FileListToArrayRec to get all of these files into an array and then loop through it reading their content, adding this content to a single text file, and then deleting them? That sounds the quickest way of doing you want. Although I would delete the files on a second pass - just in case something goes wrong. M23 Hm....but how i will be able to read this single file? is it possible put this contents(in the single file) in a struct to organize them? Can you make a simple example? thx again! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2014 Moderators Share Posted November 4, 2014 xbennY0, is it possible put this contents(in the single file) in a struct to organize them?You still have not really explained why you keep on about putting all this mass of data into a struct. What advantage does it give you over a single text file containing the content of all the files? Perhaps if you gave us a concrete example of what these files contain and what you mean by "organise" we might be a little wiser. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xbennY0 Posted November 10, 2014 Author Share Posted November 10, 2014 (edited) xbennY0, You still have not really explained why you keep on about putting all this mass of data into a struct. What advantage does it give you over a single text file containing the content of all the files? Perhaps if you gave us a concrete example of what these files contain and what you mean by "organise" we might be a little wiser. M23 Because it is easier to find one single file than 3.000. Because it transfers the program to a computer faster(with these folders takes about 15 minutes to transfer 3MB). Edited November 10, 2014 by xbennY0 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 10, 2014 Moderators Share Posted November 10, 2014 xbennY0,If all you requires is all the data in one file, then what I suggested in post #16 above should be what you need. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now