|
Try this:
BOOL bCapture = FALSE; while(fgets(buf, bufsize, fp1) != NULL)
{
tok = strtok(buf,"{ ,}");
if (tok != NULL)
{
if (bCapture == FALSE)
{
if (strcmp(tok, "EXEC") == 0)
bCapture = TRUE;
}
else {
if (strcmp(tok, "END-EXEC") == 0)
bCapture = FALSE;
else
printf("Token: %s\n", tok);
}
}
}
[edit]Fixed the "END-EXEC" string, thanks to Carlo for pointing it out.[/edit]
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
modified 10-Feb-12 6:56am.
|
|
|
|
|
My 5, though your code, as it stands, wouldn't match the-requirements.
Veni, vidi, vici.
|
|
|
|
|
I wrote it over breakfast; what's missing?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Nothing is missing, however an underscore is not an hyphen.
--Carlo The Nitpick.
Veni, vidi, vici.
|
|
|
|
|
CPallini wrote: Carlo The NitpickEagle-Eye
FTFY
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
That code was a beauty again ....
Actually... the final file after strtok() looks like the one below...
Token: DCLGEN
Token: LIBRARY
Token: ACTION
Token: LANGUAGE
Token: NAMES
Token: QUOTE
Token: COLSUFFIX
Token: IS
Token: EXEC
Token: POLICY_NO
Token: REG_NO
Token: EFFECTIVE_DATE
Token: EXPIRY_DATE
Token: CAN_EFF_DATE
Token: CAN_PRO_DATE
Token: RETURN_PREMIUM
Token: CAN_PROCESSED
Token: END-EXEC
Token: COBOL
Token: DCLCANCL
Token: POLICY_NO
Token: CN-POLICY-NO
Token: REG_NO
Token: CN-REG-NO
Token: EFFECTIVE_DATE
Token: CN-EFFECTIVE-DATE
Token: EXPIRY_DATE
Token: CN-EXPIRY-DATE
Token: CAN_EFF_DATE
Token: CN-CAN-EFF-DATE
Token: CAN_PRO_DATE
Token: CN-CAN-PRO-DATE
Token: RETURN_PREMIUM
Token: CN-RETURN-PREMIUM
Token: CAN_PROCESSED
Token: CN-CAN-PROCESSED
Token: THE
Your code cleverly extracted the strings within EXEC and END-EXEC which I stored in
char tableCol[6][10]
But now I am finding it really difficult to store the strings which are immediatedly followed by the "tabCol" string from the file...
ie CN-POLICY-NO, CN-REG-NO, CN-EFFECTIVE-DATE, CN-EXPIRY-DATE, CN-CAN-EFF-DATE, CN-CAN-PRO-DATE, CN-RETURN-PREMIUM & CN-CAN-PROCESSED which are to be stored in
char tableRow[6][10]
Apologies ...
Thanks a ton,
Faez
|
|
|
|
|
Since they all begin with "CN-", you could add a test:
if (strncmp(tok, "CN-", 3) == 0)
printf ...
Alternatively you have to test for each one individually.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
No no... It ain't always preceeded with "CN-" string ...
The strings which needs to be stored in TabRow array are followed by the second occurrence of each tableCol values...
Initially I also thought of using strcat () and append CN- to the tabCol values...
But den I realized that it was for this file only... Other files are completely different.
Regards,
Faez
|
|
|
|
|
If you don't have a common character identifier to select your strings then there is little that can be done. And from what you say you will have different rules for different files so it's difficult to suggest any other options.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Finally I have come up witha Not-so-good code... But it works..
I created another similar situation to parse from END-EXEC to End of File as below...
if (k == 0)
{
if (strcmp(tok, "END-EXEC") == 0)
k = 1;
}
else
{
if (strcmp(tok, "THE") == 0)
{
k = 0;
}
else
{
strcpy(tabRow[m],tok);m++;
fprintf(fp3,"Token: %s\n", tok);
}
}
}
}
j=0,n=0;
for(j=0;j<=m;j++)
{
if(strcmp(tabCol[n],tabRow[j])==0)
{
k=j;
strcpy(tabRow[n],tabRow[k+1]);
n++;
}
else ;
}
for(k=0;k<n-1;k++)
{
printf("No %d Element under TableCol is = %s\n", k+1,tabCol[k]);
printf("No %d Element under TableRow is = %s\n", k+1,tabRow[k]);
}
It wud be nice to get ur comments on this...
Thanks,
Faez
|
|
|
|
|
Difficult to say really. Assuming it does what you want then that's fine, but I don't see any checks for the specific strings after the "END-EXEC" that you wish to save. Or perhaps that is what the line
if(strcmp(tabCol[n],tabRow[j])==0)
is doing.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Faez Shingeri wrote: ...which are to be stored in
char tableRow[6][10] Which won't be large enough.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
hi,
i have application that disply USB cemera video .for that i have to connect with samplegraber and get image anyone please hehp me.
|
|
|
|
|
Please do not post the same question in multiple forums.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I'm baffled here. I have a listbox that I can't send a message to, but if I change CreateWindowEx from Listbox to ComboBox, and change LB_ to CB_, it works fine.
So I have 6 hours into this, and it's time to ask for help. I can't think of anything. Changing the listbox to combobox was just an experiment because I tried everything I could think of, and was surprised it worked. Plus it validates that all my pointers are correct as well.
Here is my question:
I just looking for expert knowledge in how to diagnose this and get it to work as a listbox.
lb_SetupWizard_CreateUser_LB_Field = CreateWindowEx(WS_EX_TRANSPARENT,
TEXT("ListBox"),
NULL,
LBS_HASSTRINGS | WS_TABSTOP | WS_VSCROLL | WS_CHILD | WS_VISIBLE | ES_LEFT | ES_MULTILINE,
50, 122,
300, 220,
hSetupWizard,
(HMENU)IDC_SETUPWIZARD_CREATEUSER_LISTBOX_SELECT,
GetModuleHandle(NULL),
NULL
);
SendMessage(lb_SetupWizard_CreateUser_LB_Field, WM_SETFONT, (WPARAM)hFont_SetupWizard_Label, FALSE);
ShowWindow(lb_SetupWizard_CreateUser_LB_Field, SW_HIDE);
iPosition = SendMessage( lbUserAccounts, CB_ADDSTRING, 0, (LPARAM) szDescription );
SendMessage( lbUserAccounts, CB_SETITEMDATA, iPosition, (LPARAM) (int)pzUserID );
|
|
|
|
|
jkirkerx wrote: CB_ADDSTRING
Hopefully this is a typo and you really have LB_ADDSTRING in this function.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
The send message works as a "Combobox", that's why the CB_ADDSTRING is there in the example code.
If I change the window to a "ListBox", and swap out CB_ADDSTRING with LB_ADDSTRING, it doesn't work. error code 87, but then I get a error code 87 with CB_ADDSTRING as well, but the combobox loads the text.
It seems really simple to me, CB for combo box and LB for Listbox. It's driving me nuts.
|
|
|
|
|
Have you tried SendDlgItemMessage?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
I didn't think of that,
I tried PostMessage, SendNotifyMessage
I'll give that a spin later tonight.
I'm just going to finish out the code with the combobox first.
Thanks
|
|
|
|
|
jkirkerx wrote: LBS_HASSTRINGS | WS_TABSTOP | WS_VSCROLL | WS_CHILD | WS_VISIBLE | ES_LEFT | ES_MULTILINE,
Why the use of edit-control styles?
jkirkerx wrote: (HMENU)IDC_SETUPWIZARD_CREATEUSER_LISTBOX_SELECT,
Did you mean to cast this identifier to an HMENU ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
DavidCrow wrote: Why the use of edit-control styles?
I thought I needed it to set the alignment to the left, and show as multiline
DavidCrow wrote: Why the use of edit-control styles?
I was going to make it to where you can select the user by listbox only, but it didn't work out.
Should I take them out?
I haven't tried the SendDlgItem yet, will try it today.
|
|
|
|
|
I removed the ES_left and ES_MULTILINE, and now it works as a ListBox.
As far as the (HMENU) cast goes, I'm not sure what the proper way to do it is. And I'm not sure why the Listbox works now in detail.
|
|
|
|
|
My theory:
ES_LEFT resolves to 0 and ES_MULTILINE resolves to 4 . When you were using a combobox, a value of 4 was the same as CBS_DROPDOWNLIST|CBS_SIMPLE . When you were using a listbox, a value of 4 was the same as LBS_NOREDRAW . So, the items were likely being added to the listbox but since redraw was turned off, you could not see them.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
OOOOh
I was thinking yesterday, I know the names are being added, but it looks like the listbox is not being repainted. I looked into the WM_DRAWITEM and WM_PAINT, and checked all the Proc's, they were firing, so finally I changed the Listbox to a ComboBox and it worked.
Thanks a million times over for the help David. I would of never figured it out by myself.
I changed the ES_LEFT and ES_MULTILINE before I tried the SendDlgItemMessage.
|
|
|
|
|
Hi friend,
I am working with Client Server windows(VC++ and MFC) project which is connceted via TCP IP concept. it is working fine with in a organization(LAN).but my requierment, server in one location, client in another location.
How to connect Client and Server.
Can i use virualiztion concept?
I do not know how to start.
Do you have any virualiztion concept reference website link?
Please teach me.
|
|
|
|