im just beginning this but i need a few of my questions answered first. my program will open up a file and read the contents into a buffer then display one portion of the string into one text box and the other in the other textbox. the file for now will only contain one line: 184.108.40.206:8080. the colon is the part of the string where it will split at. the colon wont show in the textboxes. 220.127.116.11 will be in one textbox and 8080 will be in another. what i dont know how to do is split up the string and what to do after that. smurf This message was edited by smurf, on 4/24/2001 8:56:28 PM
Use masm32 string functions, or you could code your own proc to do it for you. Using the string functions is probably preferible as otherwise things can get very complicated and messy for complex string maniulations but is slower.
Split PROC lpIn:DWORD,lpOut1:DWORD,lpOut2:DWORD .data colon BYTE ":",0 .code invoke InString ,1,lpIn,ADDR colon push eax dec eax invoke szLeft ,lpIn,lpOut1,eax invoke StrLen ,lpIn pop edx sub eax,edx invoke szRight ,lpIn,lpOut2,eax mov eax,TRUE ret Split ENDP
ack! i see you beat me too it, oh well i dont care, im too tired, im going to post this anyway....
yeah its slopy and i havent tested it cuz im so tired and ready for bed, so im not sure if it will even work, :] ill run through how to use it...
SplitString proc source :DWORD, dest:DWORD LOCAL cnt:BYTE ; declare counter variable mov cnt, 0 ; we will use it as 0 is inactive while 1 is active mov ecx, source ; put address into ecx mov edx, dest ; put address into edx Start: mov al, ; copy byte at address in ecx to al inc ecx ; increment address in ecx cmp cnt,1 ; are we ready to write? je Mid ; oh yeah! cmp al, ':' ; see if where at the turning point jne Start ; if not jump back mov cnt,1 ; if so 'activate' the counter mov ,0 ; clear out the ':' character jmp Start ; jmp back Mid: cmp al, 0 ; test for zero first je Endof ; exit loop on ascii zero not the character '0' mov , al ; else copy byte in al to address in edx mov , 0 ; erase the string behind us inc edx ; increment address in edx jmp Start Endof: ret SplitString endp
hope it helps! -brad This message was edited by Rage9, on 4/24/2001 11:26:06 PM
;make sure to declare the proc SplitString proto :DWORD, :DWORD . . . .code ;to invoke pass two things, the string u want to split at that point, and the other sting to get the other end invoke SplitString, addr originalstring, addr otheremptyvariable ;so the first part befor the ':' will be in originalstring and ther part after the ': should be i the otheremptyvarible passed... ;to put them into text boxes... invoke SetDlgItemText,window_handle,Control_id, addr originalstring invoke SetDlgItemText,window_handle,Control_id, addr otheremptyvarible ;there u go!
thanks George and Rage9 you both have been very helpfull. smurf