问:
C structure assignment of same address valid?
If I have something like this in my code:

```<code>void f(struct foo *x, struct foo *y)
{
  *x = *y; // structure copy (memcpy?)
}
</code>```

If x and y point to the same address, what happens?

Is this valid code, and what if the compiler converts the assignment into a memcpy call with potentially-invalid operands (they aren't allowed to overlap)?

[Yes, I know I can use "restrict" in this case, but the actual code we found which made us consider this is automatically-generated by bison so we were wondering if it should always be valid and whether the compiler should use memmove or something else which allows overlap..]

答:
[Yes, answering my own question as I saw this after looking in the standard a bit and searching harder for related questions on here]

Actually, this is answered by part of the answer to Are there any platforms where using structure copy on an fd_set (for select() or pselect()) causes problems? (in this answer), which I will paste here:

One of the following shall hold:

...

the left operand has a qualified or unqualified version of a structure or union type compatible with the type of the right;

...

If the value being stored in an object is read from another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects shall have qualified or unqualified versions of a compatible type; otherwise, the behavior is undefined.

Hence as long as the pointers are the same (i.e. total overlap) then this is fine.  Still seems odd that the compiler inserts a call to memcpy sometimes for this despite the spec of memcpy saying that overlap is not allowed.  Perhaps the compiler knows more about the particular implementation of memcpy than the documentation eludes to..

Body:
If I have something like this in my code:

void f(struct foo *x, struct foo *y)
{
  *x = *y; // structure copy (memcpy?)
}

If x and y point to the same address, what happens?

Is this valid code, and what if the compiler converts the assignment into a memcpy call with potentially-invalid operands (they aren't allowed to overlap)?

[Yes, I know I can use "restrict" in this case, but the actual code we found which made us consider this is automatically-generated by bison so we were wondering if it should always be valid and whether the compiler should use memmove or something else which allows overlap..]


来源: stackexchange

问:
Dynamics 2016 email tracking ignoring outgoing replies
We have server-side synchronisation set up for our Dynamics 2016 on-premise instance, and it is correctly sending emails from a Case, and tracking replies from the customer.  However, when an internal user replies using Outlook (without the CRM add in), their responses aren't being tracked.  This means that the email conversation consists of an initial "outgoing" email, followed by only incoming responses.

The full scenario is:

Internal user sends an email from a CRM Case.  Email tracked in CRM

Customer replies to email.  Reply tracked in CRM and goes to internal user's Outlook

Internal user sends a reply from their Outlook.  Reply is not tracked in CRM

Customer replies to email.  Reply tracked in CRM and goes to internal user's Outlook

Is it possible to allow the Internal user's replies (point 3) to be tracked in CRM without installing the Outlook add in (i.e. so it also works from the Web/mobile versions of Outlook)?

答:
I believe you cannot do this without Outlook client as per Jukka.

Without the CRM Outlook client you can’t get the information into CRM without copy-pasting it from one window to another in the aforementioned scenarios. No synchronization technology will help you here, since CRM is unaware of the item until it has been brought into its world. The “Track” button is a client-side feature that you can’t utilize with any server-side solution, which means there’s no way for a user to select an email, appointment, task or contact from the Exchange server that he or she would like to promote into a record in CRM. Since the the record wasn’t “born in CRM”, it just can’t find its way there.

Last resort would be Smart matching with Tracking token, which may help you in this scenario.

Update:

Customer reply is going to reach CRM through a monitored queue. You can read a lot & get clarity from the above link.

Deploying a solution like the CRM 2013 the server-side synchronization will take care of moving items like calendar appointments and contacts back and forth between the end-user client device and the central CRM database, but it only applies to items that already exist in the realm of CRM. What I mean by this is that the item was either originally created directly in the CRM application or it was received via a monitored location like an email queue.

Your expectation is right, it should be tracked. I would open a ticket with MS & solve this.

Once the item is in CRM, server-side sync can take care of tracking the subsequent updates to it. A re-scheduled tracked appointment will get updated with the new date, regardless of whether you change the date via CRM or your mobile phone calendar that’s linked to Exchange. An email thread with a tracked message and a tracking token ID injected into the email subject line will have the next replies automatically synchronized into CRM

ContentLicense: CC BY-SA 3.0


问:
assigning permanent custom paths to anaconda
This question has been asked, but oddly enough the answers are out of date or not sufficient.

I have installed anaconda, I have setup an environment running py2.7. I launch a win7 cmd prompt and type activate python27 (my custom python environment). I then import sys and then sys.path to see what my python paths are. They all point to variations of E:\Users\myname\Anaconda3\....

I want to add a custom path to this list so that it becomes permanent. Doing sys.path.append is not good enough as its not permanent. I have been reading that adding PYTHONPATH to the environment variables is not done any more, and that I should be adding my custom paths to the PATH system variables.

So could someone advise where and how I can assign my custom paths.

答:
Okay thanks to my instructor I found this to work for me.

open a command prompt (just regular win cmd) and add a path like this where you see the J:\pythonTest you can add your own path this will put it into your path.

SETX PYTHONPATH "%PYTHONPATH%;J:\pythonTest"

One thing I noticed, because I had been trying all sort of ways to solve this problem, my user variables and system variables and a few duplicates of my custom path. I would advise removing them once you run the above command. I suggest removing them because I think I discovered some conflicts and my modules wouldn't run, removing the duplicates seemed to fix this conflict.


问:
How to hide an Azure App Service Slot from the internet
I have "build" slot for my website hosted on azure app services. I was wondering it it would be possible to not make it available under any url. i.e. I don't want the "build" slot deployment reachable using http://mysite-build.azurewebsite.net</p>

答: Better to use AppServiceEnvironment. Its really costly to be adapted for small or medium sized apps. ASE</p>


问:
Service Fabric couldn't load assembly c#
"Could not load file or assembly 'Microsoft.ServiceFabric.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format."

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.ServiceFabric.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I added nuget of Service Fabric to my web api and here's the exception.
I tried to complie x64 / AnyCPU / x86

Any help?

答:
I faced the same issue, both for web applications and when running tests.

When running a web application : : System.BadImageFormatException :  "Could not load file or assembly 'Microsoft.ServiceFabric.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format."

Possible cause: your IIS is not setup to run in a 64 bit version. Service Fabric assemblies only run on 64 bit platforms.

Solution: In that case you need to do (as suggested above) in Visual Studio TOOLS > OPTIONS > Projects and Solutions > WEB PROJECTS and check the "Use the 64 bit version of IIS Express for web sites and projects".

When running a test : System.BadImageFormatException : "Could not load file or assembly 'Microsoft.ServiceFabric.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format."

Possible cause: your test runner is not setup to run in a 64 bit version. Service Fabric assemblies only run on 64 bit platforms.

Solution: Change the test runner settings in Visual Studio:
Test menu > Test Settings > Default Processor Architecture > Set to x64.

Also make sure that all your projects are configured to run on x64 platforms, not x86. You can ensure this in the Configuration Manager of your solution, make sure you do not have any active profile for x86.


问:
Mirth performance benchmark
We are using mirth connect for message transformation from hl7 to text and storing the transformed messages to azure sql database. Our current performance is 45000 messages per hour .

machine  configuration is
8 GB RAM and 2 core CPU. Memory assigned to mirth is -XMS = 6122MB

We don't have any idea about what could be performance parameters for Mirth with above configurations. Anyone have idea about performance benchmarks for Mirth connect?

答: We are using an AWS EC2 4c.4xlarge instance to test a bare bone Proof of Concept performance limit. We got about 50 msgs/sec without obvious bottlenecks on cpu/memory/network/disk io/db io and etc. Want to push the limits higher. Please share your observations if any. </p>

Title: Mirth performance benchmark


问:
Large eCommerce site: Is it time for HTML5?
I currently work for a large company and I design for their high-traffic ecommerce website. We support tens-of-thousands of users across a variety of browsers. Our current browser stats point to most people using either Firefox 3+ and IE8. There are about 5% of users still on IE6.

Is it time to start coding for the future and impliment HTML5 across the site? Is it a responsible thing to do or should I wait a year for people to upgrade to better supporting browsers?

Thank you.

答: ... what is "large"? Considering HTML5 is still considered work in progress, I'd vote no.</p>

ContentLicense: CC BY-SA 2.5


问:
Azure AD B2C - how is username/password exchanged for id_token?
We have a project in development that uses Azure AD B2C exclusively to authenticate users. I am in the process of preparing some documentation on how the login flow works, tracing it in Fiddler.

For a user that correctly submits their username and password to the form rendered by login.microsoftonline.com, I understand they get an id_token in response, which they then present to our website to have their authentication validated and establish a session.

In Fiddler, I see the POST to ourtenant.onmicrosoft.com which includes the correct username and password. The response body is "{"status":"200"}" with a bunch of set-cookie headers (content omitted for brevity).

```<code>x-ms-cpim-slice
x-ms-cpim-dc
x-ms-cpim-cache
x-ms-cpim-trans
</code>```

Following this, I see a GET to ourtenant.onmicrosoft.com which includes the above cookies, and ourtenant.onmicrosoft.com responds with a blob of HTML which contains the id_token in a hidden field.

My question is, in simple terms, how does Azure AD B2C correlate the correct username/password entry in the first POST to the id_token provided in response to the proceeding GET?

My rookie guess is that it uses the x-ms-cpim-cache cookie and, if so, I just want to understand what it stores and how robustly it's protected.

答:
As far as the contract is concerned, cookies are internal to B2C. Since they are generated and consumed by B2C service, the internal structure can be changed anytime.

Passwords are validated in the same request in which the user provides them, and then discarded.

B2C keeps track of the progress a user has made in the authentication process using cookie(s). Such cookie(s) are encrypted. Beyond that, it does not help to state what's in these cookie(s). Today, it could be a GUID that allows B2C to store some state in a DB, tomorrow it could be some short-lived security tokens, etc.

Body:
We have a project in development that uses Azure AD B2C exclusively to authenticate users. I am in the process of preparing some documentation on how the login flow works, tracing it in Fiddler.

For a user that correctly submits their username and password to the form rendered by login.microsoftonline.com, I understand they get an id_token in response, which they then present to our website to have their authentication validated and establish a session.

In Fiddler, I see the POST to ourtenant.onmicrosoft.com which includes the correct username and password. The response body is "{"status":"200"}" with a bunch of set-cookie headers (content omitted for brevity).

x-ms-cpim-slice
x-ms-cpim-dc
x-ms-cpim-cache
x-ms-cpim-trans

Following this, I see a GET to ourtenant.onmicrosoft.com which includes the above cookies, and ourtenant.onmicrosoft.com responds with a blob of HTML which contains the id_token in a hidden field.

My question is, in simple terms, how does Azure AD B2C correlate the correct username/password entry in the first POST to the id_token provided in response to the proceeding GET?

My rookie guess is that it uses the x-ms-cpim-cache cookie and, if so, I just want to understand what it stores and how robustly it's protected.


问:
Crash copying NSArray into NSMutableArray
I am trying to copy NSArray into NSMutableArray using the below code, but it crashes with the uncaught exception error.

Actual Response Array Result:

```<code>dataroot = (
    1,
    2,
    3
);
</code>```

Code:

```<code>@interface MobileTestViewController ()
{
    NSMutableArray *mainMutArray ;
}
@end

@implementation MobileTestViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    mainMutArray = [[NSMutableArray alloc]init];
}

NSMutableArray *responseArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];

NSArray *dataarray = [responseArray valueForKey:@“dataroot”];
mainMutArray = [[NSMutableArray alloc] initWithArray: dataarray];

@end
</code>```

Error

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xb000000000000013'

How can I properly copy that array into a NSMutableArray.

答:
It seems you're confusing NSArray and NSDictionary. Is the object you get from the JSON serialization is array or a dictionary? Use the debugger or log what kind of class this is:

NSMutableArray *responseArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];

If it's an array, the following code with crash as you don't index into arrays using string keys, you use integer indexes.

NSArray *dataarray = [responseArray valueForKey:@“dataroot”];

If the original object is a dictionary, try this code:

```<code>NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];

if (!responseDictionary) {
   // handle error
}

NSArray *dataArray = responseDictionary[@"dataroot"];
</code>```

Body:
I am trying to copy NSArray into NSMutableArray using the below code, but it crashes with the uncaught exception error.

Actual Response Array Result:

dataroot = (
    1,
    2,
    3
);

Code:

@interface MobileTestViewController ()
{
    NSMutableArray *mainMutArray ;
}
@end

@implementation MobileTestViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    mainMutArray = [[NSMutableArray alloc]init];
}

NSMutableArray *responseArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];

NSArray *dataarray = [responseArray valueForKey:@“dataroot”];
mainMutArray = [[NSMutableArray alloc] initWithArray: dataarray];

@end

Error

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xb000000000000013'

How can I properly copy that array into a NSMutableArray.

Body:
It seems you're confusing NSArray and NSDictionary. Is the object you get from the JSON serialization is array or a dictionary? Use the debugger or log what kind of class this is:

NSMutableArray *responseArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];

If it's an array, the following code with crash as you don't index into arrays using string keys, you use integer indexes.

NSArray *dataarray = [responseArray valueForKey:@“dataroot”];

If the original object is a dictionary, try this code:

NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];

if (!responseDictionary) {
   // handle error
}

NSArray *dataArray = responseDictionary[@"dataroot"];


问:
Splitting a SAS dataset into mutual-exclusive by row in parallel?
There is SO question on split a large dataset into smaller one but with the advent of proc ds2 there must a way to do this using threads?

I have written the below data step to split a dataset into &chunks. chunks. I tried to write the same in proc ds but it just fails. I am quite new to proc ds2 so a simple explanation for someone with good understanding of data step would be ideal.

Data stepcode

```<code>%macro output_chunks(in, out, by, chunks);
data %do i = 1 %to &chunks.;
    &out.&i.(compress=char drop = i)
    %end;
;
    set &in.;
    by &by.;
    retain i 0;
    if first.&by. then do;
        i = i + 1;
        if i = &chunks.+1 then i = 1;
    end;

    %do i = 1 %to &chunks.;
        if i = &i. then do;
            output  &out.&i.;
        end;
    %end;
run;
%mend;
</code>```

proc ds2 code

```<code>proc ds2;
  thread split/overwrite=yes;
    method run();
      set in_data;
      thisThread=_threadid_;
      /* can make below into macro but I can't seem to get it to work */
      if thisThread = 1 then do;
        output ds1;
      end;
      else if thisThread = 2 then do;
        output ds2;
      end;
    end;
    method term();
      put '**Thread' _threadid_ 'processed'  count 'rows:';
    end;
  endthread;
  run;
quit;
</code>```

答:
So, you're right in one sense that DS/2 may be helpful here.  However, I suspect it's a bit more complicated.

DS/2 will happily thread data steps, but what is going to be more challenging is writing to several different datasets.  That's because there's not a great way to structure the output dataset name without using the macro language, which won't play with the threading very well as far as I can tell (though I'm no expert here).

Here's an example of it using threading:

```<code>PROC DS2;

     thread in_thread/overwrite=yes;
     dcl bigint count;
     drop count;
        method init();
           count=0;
        end;
         method run();
             set in_data;
             count+1;
             output;
         end;
         method term();
           put 'Thread' _threadid_ ' processed' count 'observations.';
         end;
     endthread;
     run;

     data out_data/overwrite=yes;
         dcl thread in_thread t_in; /* instance of the thread */
         method run();
           set from t_in threads=4;
           output;
         end;
     enddata;
     run;
quit;
</code>```

But this just writes one dataset out, and if you change threads=4 to 1, it doesn't actually take any longer.  Both are okay speed-wise, though actually slower than the regular data step (about 1.8x the speed for me).  DS/2 uses a much, much slower method to access data under the hood than SAS's base data step when accessing SAS datasets; DS/2's speed gains really come into play when you're working in RDBMSs via SQL or similar.

However, there's no good way to drive the output in parallel.  Here's the version of the above turned into making 4 datasets.  Notice that the actual selection of where to output is in the main, non-threaded data step...

```<code>PROC DS2;

     thread in_thread/overwrite=yes;
     dcl bigint count;
     dcl bigint thisThread;
     drop count;
        method init();
           count=0;
        end;
         method run();
             set in_data;
             count+1;
             thisThread = _threadid_;
             output;

         end;
         method term();
           put 'Thread' _threadid_ ' processed' count 'observations.';
         end;
     endthread;
     run;

     data a b c d/overwrite=yes;
         dcl thread in_thread t_in; /* instance of the thread */
         method run();
           set from t_in threads=4;
           select(thisThread);
             when (1) output a;
             when (2) output b;
             when (3) output c;
             when (4) output d;
             otherwise;
           end;
         end;
     enddata;
     run;
quit;
</code>```

So it's actually quite a lot slower than in the non-threaded version.  Oops!

Really, your issue here is that disk i/o is the main problem, not CPU.  Your CPU does virtually no work here.  DS/2 might be able to help in some edge cases where you have a really fast SAN that allows tons of simultaneous writes, but ultimately it takes X amount of time to read those million records and same X amount of time to write a million records, based on your i/o constraint, and odds are parallelizing that won't help.

Hash tables will add a lot more I suspect, and could certainly be used here with DS/2; see my new answer on the other question linked in OP for the data step version.  DS/2 probably won't make that solution any faster, more likely slower; but you could implement roughly the same thing in DS/2 if you wanted, and then the sub-thread would be able to output on its own without involving the master thread.

Where DS/2 would be helpful would be if you're doing this in Teradata or something, where you can use SAS's in-database accelerator to execute this code database-side.  That would make things a lot more efficient.  Then you could use something similar to my code above, or better yet a hash solution.

Body:
There is SO question on split a large dataset into smaller one but with the advent of proc ds2 there must a way to do this using threads?

I have written the below data step to split a dataset into &chunks. chunks. I tried to write the same in proc ds but it just fails. I am quite new to proc ds2 so a simple explanation for someone with good understanding of data step would be ideal.

Data stepcode

%macro output_chunks(in, out, by, chunks);
data %do i = 1 %to &chunks.;
    &out.&i.(compress=char drop = i)
    %end;
;
    set &in.;
    by &by.;
    retain i 0;
    if first.&by. then do;
        i = i + 1;
        if i = &chunks.+1 then i = 1;
    end;

    %do i = 1 %to &chunks.;
        if i = &i. then do;
            output  &out.&i.;
        end;
    %end;
run;
%mend;

proc ds2 code

proc ds2;
  thread split/overwrite=yes;
    method run();
      set in_data;
      thisThread=_threadid_;
      /* can make below into macro but I can't seem to get it to work */
      if thisThread = 1 then do;
        output ds1;
      end;
      else if thisThread = 2 then do;
        output ds2;
      end;
    end;
    method term();
      put '**Thread' _threadid_ 'processed'  count 'rows:';
    end;
  endthread;
  run;
quit;

Body:
So, you're right in one sense that DS/2 may be helpful here.  However, I suspect it's a bit more complicated.

DS/2 will happily thread data steps, but what is going to be more challenging is writing to several different datasets.  That's because there's not a great way to structure the output dataset name without using the macro language, which won't play with the threading very well as far as I can tell (though I'm no expert here).

Here's an example of it using threading:

PROC DS2;

     thread in_thread/overwrite=yes;
     dcl bigint count;
     drop count;
        method init();
           count=0;
        end;
         method run();
             set in_data;
             count+1;
             output;
         end;
         method term();
           put 'Thread' _threadid_ ' processed' count 'observations.';
         end;
     endthread;
     run;

     data out_data/overwrite=yes;
         dcl thread in_thread t_in; /* instance of the thread */
         method run();
           set from t_in threads=4;
           output;
         end;
     enddata;
     run;
quit;

But this just writes one dataset out, and if you change threads=4 to 1, it doesn't actually take any longer.  Both are okay speed-wise, though actually slower than the regular data step (about 1.8x the speed for me).  DS/2 uses a much, much slower method to access data under the hood than SAS's base data step when accessing SAS datasets; DS/2's speed gains really come into play when you're working in RDBMSs via SQL or similar.

However, there's no good way to drive the output in parallel.  Here's the version of the above turned into making 4 datasets.  Notice that the actual selection of where to output is in the main, non-threaded data step...

PROC DS2;

     thread in_thread/overwrite=yes;
     dcl bigint count;
     dcl bigint thisThread;
     drop count;
        method init();
           count=0;
        end;
         method run();
             set in_data;
             count+1;
             thisThread = _threadid_;
             output;

         end;
         method term();
           put 'Thread' _threadid_ ' processed' count 'observations.';
         end;
     endthread;
     run;

     data a b c d/overwrite=yes;
         dcl thread in_thread t_in; /* instance of the thread */
         method run();
           set from t_in threads=4;
           select(thisThread);
             when (1) output a;
             when (2) output b;
             when (3) output c;
             when (4) output d;
             otherwise;
           end;
         end;
     enddata;
     run;
quit;

So it's actually quite a lot slower than in the non-threaded version.  Oops!

Really, your issue here is that disk i/o is the main problem, not CPU.  Your CPU does virtually no work here.  DS/2 might be able to help in some edge cases where you have a really fast SAN that allows tons of simultaneous writes, but ultimately it takes X amount of time to read those million records and same X amount of time to write a million records, based on your i/o constraint, and odds are parallelizing that won't help.

Hash tables will add a lot more I suspect, and could certainly be used here with DS/2; see my new answer on the other question linked in OP for the data step version.  DS/2 probably won't make that solution any faster, more likely slower; but you could implement roughly the same thing in DS/2 if you wanted, and then the sub-thread would be able to output on its own without involving the master thread.

Where DS/2 would be helpful would be if you're doing this in Teradata or something, where you can use SAS's in-database accelerator to execute this code database-side.  That would make things a lot more efficient.  Then you could use something similar to my code above, or better yet a hash solution.


问:
C# saving and then retriving data via the clipboard
Okay,

So I have a program that automatically copies data to the clipboard and then into memory.  What I want to do is, to save the data that is on the clipboard prior to my program running and then to copyit back to the clipboard once I have finished what I need to do.

I can get the data fromt he clipboard as such:

```<code>IDataObject currentClipboard = Clipboard.GetDataObject();
</code>```

However, when I want to put the data back on to the clipboard, do I need to know what format that data is in to cast it?

Is there a way to do this?

Thanks.

答:
See this post, it might have what you need:

Strangeness with clipboard access

Body:
Okay,

So I have a program that automatically copies data to the clipboard and then into memory.  What I want to do is, to save the data that is on the clipboard prior to my program running and then to copyit back to the clipboard once I have finished what I need to do.

I can get the data fromt he clipboard as such:

IDataObject currentClipboard = Clipboard.GetDataObject();

However, when I want to put the data back on to the clipboard, do I need to know what format that data is in to cast it?

Is there a way to do this?

Thanks.


问:
Call to undefined function iconv() fatal error - Suitecrm
Using suitecrm 7.9.1

I am facing the below error whenever i try to create a lead , that is after submitting the create lead form.

Facing the same error whenever i try to import a csv file . This error occurs only on live server

Fatal error: Uncaught Error: Call to undefined function iconv() in
/home/testsite/public_html/modules/AOD_Index/Lib/Zend/Search/Lucene/Field.php:222
Stack trace: #0
/home/testsite/public_html/modules/AOD_Index/Lib/Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php(131):
Zend_Search_Lucene_Field->getUtf8Value() #1
/home/testsite/public_html/modules/AOD_Index/Lib/Zend/Search/Lucene/Index/Writer.php(244):
Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter->addDocument(Object(Zend_Search_Lucene_Document))

2 /home/testsite/public_html/modules/AOD_Index/Lib/Zend/Search/Lucene.php(1410):

Zend_Search_Lucene_Index_Writer->addDocument(Object(Zend_Search_Lucene_Document)) #3 /home/testsite/public_html/modules/AOD_Index/AOD_Index.php(310): Zend_Search_Lucene->addDocument(Object(Zend_Search_Lucene_Document))

4 /home/testsite/public_html/modules/AOD_Index/AOD_LogicHooks.php(36):

AOD_Index->index('Leads', 'b81874eb-1233-5...') #5
/home/testsite/public_html/include/utils/LogicHook.php(262):
AOD_LogicHooks->saveModuleChanges(Object(L in
/home/testsite/public_html/modules/AOD_Index/Lib/Zend/Search/Lucene/Field.php
on line 222

what is the cause for this error .
newbie to the suitecrm, how to fix it .

答:
Install the Iconv module on your CPanel.

Open WHM

EasyApache 4

Customize

PHP extensions

Find iconv. Enable the one matches your PHP version

Review

Provision

ContentLicense: CC BY-SA 4.0


问:
Multi-tenant app in Azure AD (Active Directory) fails with AADSTS50020
I created a "Web app / API" app in our organization's "xxx.onmicrosoft.com" Azure Active Directory. The app's "Multi-tenanted" property has been set to "Yes".

We configured OpenID Connect (we use https://github.com/mitreid-connect/) to use the following URLs:

https://login.microsoftonline.com/common/oauth2/authorize

https://login.microsoftonline.com/common/oauth2/token

Please note that we used "common" in the URLs and we didn't use "xxx.onmicrosoft.com" because we want people from outside "xxx.onmicrosoft.com" to be able to authenticate and access our app.

With those settings, the people from xxx.onmicrosoft.com can properly authenticate and access the app.

However, when I use my personal live.com account (with username xxx@gmail.com) to access the app, I get AADSTS50020 error. I am able to properly authenticate with my xxx@gmail.com account, but I do not get redirected to the Reply URL. I'm stuck on Microsoft's Web page with the following error msg:

AADSTS50020: User account 'xxx@gmail.com' from identity provider
  'live.com' does not exist in tenant 'xxx.onmicrosoft.com' and cannot
  access the application '391e7103-ZZZZ-zz87-xxxx-7xxxxxd5xxxx' in that
  tenant. The account needs to be added as an external user in the
  tenant first. Sign out and sign in again with a different Azure Active
  Directory user account.

What configuration do I need to change if I want people from any identity provider to be able to access my app ?

Like it has been stated here, I expected that people from anywhere could access my app without requiring more configuration on my side.

I'm asking this question because I'm in the process of getting certified for AppSource and this currently blocks me from being able to do so.

答:
AppSource only requires work accounts to sign-in. You are using an @gmail account - which is a personal account - and because you are using the Azure Active Directory v1 endpoint in addition to common (https://login.microsoftonline.com/common), it can't accept personal accounts to sign-in directly - only work accounts.

You have three options:

If sign-in personal accounts is not a requirement for your application, then you can continue using the v1 endpoint and use a work account to sign-in/test your application. This will make you ready for AppSource certification.

If you need/ want to allow personal accounts in your application in addition to work accounts, then you can consider using the v2 endpoint (https://login.microsoftonline.com/common/v2.0) for Azure Active Directory. The v2 endpoint allow both personal accounts and work accounts to sign-in with no effort.
A note is the v2 endpoint has some limitations: if you can live with these limitations (for example, your application only needs to sign-in users and eventually make queries against Graph API), then in general it should be fine to use, but if you need extra features like protecting your own Web API with scopes, then this feature is not released at this point (as November 2017). Please read this document for an updated list of limitations of the v2 endpoint.

A third (but less recommended option for AppSource) is to keep using the v1 endpoint and make your application to be single tenant - which is to change the endpoint from https://login.microsoftonline.com/common to https://login.microsoftonline.com/{yourtenantid}, and then use B2B invitations API to invite every external users (including work and personal accounts) to be part of your Azure AD tenant/organization. More information about B2B here as well.

The option '3' above have some consequences for management as well for AppSource: by using this option, you are required to have one Azure Active Directory tenant (if you don't have a tenant already, you can get one using these instructions), and the users being invited will be guests accounts of this tenant - this mean that you need to invite every external user to your application/ tenant. A multi-tenant application allows any user from any organization to sign-in to your application with less management on your side. In general for SaaS applications, multi-tenant configuration is recommended.

For AppSource, also the option '3' leads to a less-immersive user experience (Partner led trial), where the end user won't be able to access your application's demo right away - mainly because that they have to wait for the invitation's email and accept it (user has to accept being guest of your tenant) so that they can access your application.

For more information about AppSource requirements and trial options - please see this article.


问:
HttpListenerResponse adding a 2nd cookie makes all cookies disappear
I have the following code:

```<code>    void WriteConnectionId(HttpListenerContext context, string id)
    {
        var cookie = context.Response.Cookies[CookieConnectionId];
        if (cookie == null)
        {
            cookie = new Cookie(CookieConnectionId, id)
            {
                HttpOnly = true,
                Secure = true,
                Path = "/"
            };
            context.Response.Cookies.Add(cookie);
        }
        else
        {
            cookie.Value = id;
        }
        //context.Response.SetCookie(new Cookie("lalala", "lololo"));
    }
</code>```

This code stores correctly the cookie for "connection Id" in the client. In Chrome's console I can see the cookie in the list of cookies.

However, if I uncomment the last line that adds an extra cookie, then neither the session cookie or the dummy cookie make it to the client. They do not appear in Chrome's console.

Edit: removing the "/" path on the first cookie makes the first cookie appear, though with both values from the 1st and 2nd cookie concatenated with a comma.

答:
I ended up fixing this issue by creating the following function:

```<code>    void FlushCookie(HttpListenerContext context, Cookie cookie)
    {
        var builder = new StringBuilder();
        builder.Append(cookie.Name);
        builder.Append("=");
        builder.Append(HttpUtility.HtmlAttributeEncode(cookie.Value));
        builder.Append(";");
        context.Response.Headers.Add(HttpResponseHeader.SetCookie, builder.ToString());
    }
</code>```

This can be modified further to add cookie expiration, path, etc.

Body:
I have the following code:

    void WriteConnectionId(HttpListenerContext context, string id)
    {
        var cookie = context.Response.Cookies[CookieConnectionId];
        if (cookie == null)
        {
            cookie = new Cookie(CookieConnectionId, id)
            {
                HttpOnly = true,
                Secure = true,
                Path = "/"
            };
            context.Response.Cookies.Add(cookie);
        }
        else
        {
            cookie.Value = id;
        }
        //context.Response.SetCookie(new Cookie("lalala", "lololo"));
    }

This code stores correctly the cookie for "connection Id" in the client. In Chrome's console I can see the cookie in the list of cookies.

However, if I uncomment the last line that adds an extra cookie, then neither the session cookie or the dummy cookie make it to the client. They do not appear in Chrome's console.

Edit: removing the "/" path on the first cookie makes the first cookie appear, though with both values from the 1st and 2nd cookie concatenated with a comma.

Body:
I ended up fixing this issue by creating the following function:

    void FlushCookie(HttpListenerContext context, Cookie cookie)
    {
        var builder = new StringBuilder();
        builder.Append(cookie.Name);
        builder.Append("=");
        builder.Append(HttpUtility.HtmlAttributeEncode(cookie.Value));
        builder.Append(";");
        context.Response.Headers.Add(HttpResponseHeader.SetCookie, builder.ToString());
    }

This can be modified further to add cookie expiration, path, etc.


问:
"Gradle error after Android Studio update"

Today I updated Android  Studio to version 3.0

And after that I couldn't build project successfully.

I got these errors:

```<code>Unable to resolve dependency for ':app@release/compileClasspath': could not resolve com.android.support:appcompat-v7:27.0.1.
</code>```

I tried using VPN or proxy etc. but none of them worked.

It's been a long day. I hope you may help me.

This is my build.gradle(app) :

```<code>apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "ir.hetbo.kotlin_tutorial"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
</code>```

and this is build.gradle(project):

```<code>// Top-level build file where you can add configuration options common to
all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.1.60'
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
</code>```

I did a lot of things to fix it but every time it failed.

I use gradle 4.3.1

And here is gradle wrapper properties :

```<code>#Sat Nov 18 10:16:45 IRST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip
</code>```

答:
There is one build.gradle file for whole projects and one for each modules.
Need to add below code in the application build.gradle file.</p>

```<code> buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.2'
        }
    }

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
</code>```

Body:
Today I updated Android  Studio to version 3.0

And after that I couldn't build project successfully.

I got these errors:

Unable to resolve dependency for ':app@release/compileClasspath': could not resolve com.android.support:appcompat-v7:27.0.1.

I tried using VPN or proxy etc. but none of them worked.

It's been a long day. I hope you may help me.

This is my build.gradle(app) :

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "ir.hetbo.kotlin_tutorial"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}

and this is build.gradle(project):

// Top-level build file where you can add configuration options common to
all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.1.60'
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

I did a lot of things to fix it but every time it failed.

I use gradle 4.3.1

And here is gradle wrapper properties :

#Sat Nov 18 10:16:45 IRST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip

Body:
There is one build.gradle file for whole projects and one for each modules.
Need to add below code in the application build.gradle file.

 buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.2'
        }
    }

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }


问:
Placeholder in Contactform 7 - Wordpress
I am making a website for a client of me but im running into a problem.
I've made a contact form in wordpress using Contact Form 7. This plugin is really easy to use but when i wanted to use the placeholder property of the plugin it did not show the placeholder when i loaded the page.

This is how i set the placeholder in Contactform 7

```<code>[text* your-name placeholder "Name"]
</code>```

The placeholder tag works just fine for my textarea but it doesnt work with the textbox above.
Can someone explain to me what i am doeing wrong here?

EDIT

When i inspect the element with Google Chrome and inspect the textbox it says that it has a placeholder. But it doesnt show the placeholder.

答:
If anyone is having trouble with this, it could be that you're using class: or id: attributes.

It worked for me when I added placeholder after all those:

```<code>[email* your-email id:your-email class:form-control placeholder "ex. Jon.Smith@email.com"]
</code>```

Body:
I am making a website for a client of me but im running into a problem.
I've made a contact form in wordpress using Contact Form 7. This plugin is really easy to use but when i wanted to use the placeholder property of the plugin it did not show the placeholder when i loaded the page.

This is how i set the placeholder in Contactform 7

[text* your-name placeholder "Name"]

The placeholder tag works just fine for my textarea but it doesnt work with the textbox above.
Can someone explain to me what i am doeing wrong here?

EDIT

When i inspect the element with Google Chrome and inspect the textbox it says that it has a placeholder. But it doesnt show the placeholder.

Body:
If anyone is having trouble with this, it could be that you're using class: or id: attributes.

It worked for me when I added placeholder after all those:

[email* your-email id:your-email class:form-control placeholder "ex. Jon.Smith@email.com"]


问:
Need a Regex to Parse This Line 58.21 -13.73 57 -1
Need help parsing the numbers from this line in Lua.

```<code>58.21 -13.73 57 -1
</code>```

I currently am at this: [1-9][0-9] which I know is not correct as it does not return the minus and does not handle the decimal.

Thanks,

Dave

Body:
Need help parsing the numbers from this line in Lua.

58.21 -13.73 57 -1

I currently am at this: [1-9][0-9] which I know is not correct as it does not return the minus and does not handle the decimal.

Thanks,

Dave

Body:
In Lua:

(%-?%d+%.?%d+)%s+(%-?%d+%.?%d+)%s+(%-?%d+%.?%d+)%s+(%-?%d+%.?%d+)

Example:

local a, b, c, d = ("58.21 -13.73 57 -1"):match(
    "(%-?%d+%.?%d*)%s+(%-?%d+%.?%d*)%s+(%-?%d+%.?%d*)%s+(%-?%d+%.?%d*)"
  )
print(a, b, c, d) --> 58.21 -13.73  57  -1

You may (or may not) want to convert returned values to numbers.


问:
Bootstrap modal not scrolling in landscape mode on iPhone
I have a bootstrap modal on a page in my Rails application as follows:

```<code><div class='modal-dialog'>
  <div class='modal-content'>
    <div class="modal-header">
      Sign In
    </div>
    <div class='modal-body'>
      <div id="sign-in-errors" class="alert alert-error"></div>
        <%= form_for User.new, as: :user, remote: true, url: create_new_session_path, html: { id: 'sign-in-form' } do |f| %>
          <div class="form-group">
            <%= f.label :email, 'Email' %><br />
            <%= f.email_field :email, autocomplete: "off", class: 'form-control' %>
          </div>

          <div class="form-group">
            <%= f.label :password, 'Password' %><br />
            <%= f.password_field :password, autocomplete: "off", class: 'form-control' %>
          </div>

          <div class="form-group">
            <%= f.check_box :remember_me %>
            <%= f.label :remember_me, 'Remember Me', class: 'sign-in-remember-me-label' %>
          </div>

          <div class="form-group">
            <%= f.submit 'Sign In', class: "btn btn-blue btn-block btn-accounts sign-in-button pull-left" %>
            <%= link_to 'Cancel', "#", type: :reset, class: "btn btn-default btn-accounts pull-right cancel-button", "data-dismiss": "modal", "aria-hidden": "true"  %>
            <br/><br/>
            <div class='forgot-password'>
              <%= link_to 'Forgot Password', recover_password_path %>
            </div>
          </div>
      <% end %>
    </div>
  </div>
</div>
</code>```

On my iPhone 6, the modal works fine in portrait mode (vertical orientation) but when i switch the phone to landscape mode (horizontal orientation) the modal does not scroll, just the background scrolls, because of which im unable to see the 'Forgot Password' link in the modal in landscape mode on my iPhone 6.

I am using the following css for the modal

```<code>  .modal-header {
    background-color: #F0F0F0;
  }

  .modal-content  {
    -webkit-border-radius: 0px !important;
    -moz-border-radius: 0px !important;
    border-radius: 0px !important;
  }
</code>```

I checked on Android phone and the modal scrolls fine in both portrait and landscape mode. How can i make it scroll normally in landscape mode on iPhone ?

答:
There seems to have been an issue with bootstrap not scrolling with modals on iPhones.  have you checked out these links they supposedly solved teh issue by using CSS

twitter bootstrap 3 modal on mobile scroll issues

Modal box on iPhone no scroll

Body:
I have a bootstrap modal on a page in my Rails application as follows:

      Sign In

        <%= form_for User.new, as: :user, remote: true, url: create_new_session_path, html: { id: 'sign-in-form' } do |f| %>

            <%= f.label :email, 'Email' %>

            <%= f.email_field :email, autocomplete: "off", class: 'form-control' %>

            <%= f.label :password, 'Password' %>

            <%= f.password_field :password, autocomplete: "off", class: 'form-control' %>

            <%= f.check_box :remember_me %>
            <%= f.label :remember_me, 'Remember Me', class: 'sign-in-remember-me-label' %>

            <%= f.submit 'Sign In', class: "btn btn-blue btn-block btn-accounts sign-in-button pull-left" %>
            <%= link_to 'Cancel', "#", type: :reset, class: "btn btn-default btn-accounts pull-right cancel-button", "data-dismiss": "modal", "aria-hidden": "true"  %>

              <%= link_to 'Forgot Password', recover_password_path %>

      <% end %>

On my iPhone 6, the modal works fine in portrait mode (vertical orientation) but when i switch the phone to landscape mode (horizontal orientation) the modal does not scroll, just the background scrolls, because of which im unable to see the 'Forgot Password' link in the modal in landscape mode on my iPhone 6.

I am using the following css for the modal

  .modal-header {
    background-color: #F0F0F0;
  }

  .modal-content  {
    -webkit-border-radius: 0px !important;
    -moz-border-radius: 0px !important;
    border-radius: 0px !important;
  }

I checked on Android phone and the modal scrolls fine in both portrait and landscape mode. How can i make it scroll normally in landscape mode on iPhone ?


问:
Problems with int/String linked lists and variables
I am having some trouble creating a linked list in Java. All of the guides I am following give examples using some kind of variable of type String, but the list I must create needs a type int. Using the type int will produce an error message when I try to call something like position.link because it says it cannot convert an int to a string.

For clarity, the main program should have Scanner ask for the int, and use that int to create a loop that creates each node. I have messed around with iterators and with just simple singular linked lists but I am not getting anywhere.

```<code>import java.util.NoSuchElementException;
public class SuitorLinkedList<Integer>
{
   private class SuitorListNode
   {
      private int suitor;
      private SuitorListNode link;

      public SuitorListNode()
      {
         suitor = 0;
         link = null;
      }

      public SuitorListNode(int newSuitor, SuitorListNode linkValue)
      {
         suitor = newSuitor;
         link = linkValue;
      }
   } // End of SuitorListNode inner class

   public class SuitorListIterator
   {
      public SuitorListNode position;
      private SuitorListNode previous; // previous value of position

      public SuitorListIterator()
      {
         position = head; // variable head of outer class
         previous = null;
      }

      public void restart()
      {
         position = head;
         previous = null;
      }

      public String next()
      {
         if(!hasNext())
            throw new NoSuchElementException();

         String toReturn = position.suitor;
         previous = position;
         position = position.link;
         return toReturn;
      }

      public boolean hasNext()
      {
         return (position != null); // Throws IllegalStateExpression if false
      } // Returns next value to be returned by next()

      public String peak()
      {
         if(!hasNext())
            throw new IllegalStateException();
         return position.suitor;
      }

      public void addHere(int newData)
      {
         if(position == null && previous != null) // At end of list, add to end
            previous.link = new SuitorListNode(newData, null);
         else if(position == null || previous == null) // List empty or position is head node
            head = new SuitorListNode(newData, head);
         else // previous and position are consecutive nodes
         {
            SuitorListNode temp = new SuitorListNode(newData, position);
            previous.link = temp;
            previous = temp;
         }
      }

      public void delete()
      {
         if(position == null)
            throw new IllegalStateException();
         else if (previous == null) // remove node at head
         {
            head = head.link;
            position = head;
         }
         else // previous and position are consecutive nodes
         {
            previous.link = position.link;
            position = position.link;
         }
      }

      private SuitorListNode head;
   }
   public SuitorListIterator iterator()
   {
      return new SuitorListIterator();
   }
}
</code>```

I get this error every time I try, I've tried searching it up and using the toString() to help but it won't work:

```<code>SuitorLinkedList.java:60: error: incompatible types: int cannot be converted to String
         return position.suitor;
                        ^
</code>```

I have tried creating the regular linked list and got this far:

```<code>public class SuitorList
{
   public class SuitorNode
   {
      public int suitor;
      public SuitorNode link;

      public SuitorNode()
      {
         suitor = 0;
         link = null;
      } // Initialize veriables

      public SuitorNode(int newSuitor, SuitorNode linkValue)
      {
         suitor = newSuitor;
         link = linkValue;
      } // Assigns values sent in from main
   } // End inner class

   private SuitorNode head; // Variable head of type SuitorNode (callback to Node program)
   // Allows head to point to a node

   public SuitorList()
   {
      head = null;
   } // Initialize variables
   // Memory space called head filled with null

   public void addToStart(int suitorNum)
   {
      head = new SuitorNode(suitorNum, head);
   }

   // Creates node with head pointing to it at start of list
   // head will have a definition as an object with a suitor and link = head
   // If head = null, then link = null
   // head is repositioned to point to node

   public int size() // Reads size of list
   {
      int count = 0;
      SuitorNode position = head; // Variable position of type SuitorNode will equal value at head; position points where head is pointing
      while(position != null) // While list is not empty/ended
      {
         count++; // increase number of entries detected
         position = position.link; // getLink will make position = link, leading to next entry in list
      }
      return count; // Display size.
   }

   public void outputList()
   {
      SuitorNode position = head; // Position points to same thing head points to

      while(position != null) // While list is not empty/ended
      {
         System.out.println(position.suitor); // Print suitor
         position = position.link; // Go to next entry
      }
   }

   public void deleteNode(int count)
   {
      int moveCount = count - 1;
      SuitorNode position = head;

      while(head != link) // not winning
      {
         moveCount = count;
         checkEnd(); // Checks for win before causing potential problem with 1 suitor left
         checkTwoNumbersLeft(moveCount); // Takes care of movement when two nodes are left
         checkEndNode(moveCount); // Checks when, for example, 2 nodes away

         if(moveCount == count) // If checkEndNode and checkTwoNumbersLeft fail
         {
            position = position.link; // Move for first time
            moveCount = moveCount - 1;
         }

         checkEnd();
         checkEndNode2(moveCount); // When one movement is made already, deletes end node after

         if(moveCount == moveCount - 1) // if checkEndNode2 fails
            position = position.link.link; // 2nd deletion
         count = moveCount;
      }

      isWinner();
   } // End method deleteNode()

   public void checkTwoNumbersLeft(int moveCount)
   {
      SuitorNode position;
      if(position.link.link == null) // example: 1 5
      {
         createLoop();
         position = position.link.link; // Deletes the 5
         moveCount = moveCount - 2;
      } // Used just in case only two numbers are present
   } // End method checkTwoNumbersLeft()

   public void checkEnd()
   {
      SuitorNode position;
      if(position.link == null) // If at end of list
      {
         createLoop(); // creates a loop if the initial number has no next value
         isWinner(); // If a 1 is used, the entire if statement will trigger
      } // if true, head == link which will fall out of while in deleteNode()
   } // End method checkEnd()

   public void isWinner()
   {
      SuitorNode link;
      SuitorNode position;
      if(position == position.link)
      {
         head = link;
         System.out.println("The winner is Suitor " + position + "!");
      }
   } // End method isWinner()

   public void checkEndNode2(int moveCount)
   {
      SuitorNode position;
      SuitorNode link;

      if(position.link.link == null) // 1 movement
      {
         position.link = null;
         createLoop();
         isWinner();
         moveCount = moveCount - 1;
      }
   } // End checkEndNode2()

   public void checkEndNode(int moveCount)
   {
      SuitorNode position;
      SuitorNode link;

      if(position.link.link.link == null) // no movements
      {
         position = position.link;
         position.link = null;
         createLoop();
         isWinner();
         moveCount = moveCount - 2;
      }
   } // End checkEndNode()

   public void createLoop()
   {
      SuitorNode position;
      SuitorNode link;

      if(link == null) // if at the end of the list
         link = head; // Sets link to point to where head points, AKA beginning of list
   } // End createLoop()
}
</code>```

But when I do this, the variables link, position, and head always say they are not initialized unless I place them inside the method (which can mess up my code if I call the method while in the middle of the list).

My questions boil down to 1) How would I be able to convert the ints to strings in order to work with a linked list? and 2) Why are the variables in the program SuitorList requiring me to reinitialize them in every instance when I've tried placing them everywhere I could?

答:
The issue is your peek function is defined as the wrong type

```<code>public String peak()
{
    if(!hasNext())
        throw new IllegalStateException();
    return position.suitor;
}
</code>```

It's defined as returning a String

Instead it should be defined as suitor's type, an int

```<code>public int peak()
{
    if(!hasNext())
        throw new IllegalStateException();
    return position.suitor;
}
</code>```

Same issue with public String next(), should instead be public int next()

Body:
I am having some trouble creating a linked list in Java. All of the guides I am following give examples using some kind of variable of type String, but the list I must create needs a type int. Using the type int will produce an error message when I try to call something like position.link because it says it cannot convert an int to a string.

For clarity, the main program should have Scanner ask for the int, and use that int to create a loop that creates each node. I have messed around with iterators and with just simple singular linked lists but I am not getting anywhere.

import java.util.NoSuchElementException;
public class SuitorLinkedList<Integer>
{
   private class SuitorListNode
   {
      private int suitor;
      private SuitorListNode link;

      public SuitorListNode()
      {
         suitor = 0;
         link = null;
      }

      public SuitorListNode(int newSuitor, SuitorListNode linkValue)
      {
         suitor = newSuitor;
         link = linkValue;
      }
   } // End of SuitorListNode inner class

   public class SuitorListIterator
   {
      public SuitorListNode position;
      private SuitorListNode previous; // previous value of position

      public SuitorListIterator()
      {
         position = head; // variable head of outer class
         previous = null;
      }

      public void restart()
      {
         position = head;
         previous = null;
      }

      public String next()
      {
         if(!hasNext())
            throw new NoSuchElementException();

         String toReturn = position.suitor;
         previous = position;
         position = position.link;
         return toReturn;
      }

      public boolean hasNext()
      {
         return (position != null); // Throws IllegalStateExpression if false
      } // Returns next value to be returned by next()

      public String peak()
      {
         if(!hasNext())
            throw new IllegalStateException();
         return position.suitor;
      }

      public void addHere(int newData)
      {
         if(position == null && previous != null) // At end of list, add to end
            previous.link = new SuitorListNode(newData, null);
         else if(position == null || previous == null) // List empty or position is head node
            head = new SuitorListNode(newData, head);
         else // previous and position are consecutive nodes
         {
            SuitorListNode temp = new SuitorListNode(newData, position);
            previous.link = temp;
            previous = temp;
         }
      }

      public void delete()
      {
         if(position == null)
            throw new IllegalStateException();
         else if (previous == null) // remove node at head
         {
            head = head.link;
            position = head;
         }
         else // previous and position are consecutive nodes
         {
            previous.link = position.link;
            position = position.link;
         }
      }

      private SuitorListNode head;
   }
   public SuitorListIterator iterator()
   {
      return new SuitorListIterator();
   }
}

I get this error every time I try, I've tried searching it up and using the toString() to help but it won't work:

SuitorLinkedList.java:60: error: incompatible types: int cannot be converted to String
         return position.suitor;
                        ^

I have tried creating the regular linked list and got this far:

public class SuitorList
{
   public class SuitorNode
   {
      public int suitor;
      public SuitorNode link;

      public SuitorNode()
      {
         suitor = 0;
         link = null;
      } // Initialize veriables

      public SuitorNode(int newSuitor, SuitorNode linkValue)
      {
         suitor = newSuitor;
         link = linkValue;
      } // Assigns values sent in from main
   } // End inner class

   private SuitorNode head; // Variable head of type SuitorNode (callback to Node program)
   // Allows head to point to a node

   public SuitorList()
   {
      head = null;
   } // Initialize variables
   // Memory space called head filled with null

   public void addToStart(int suitorNum)
   {
      head = new SuitorNode(suitorNum, head);
   }

   // Creates node with head pointing to it at start of list
   // head will have a definition as an object with a suitor and link = head
   // If head = null, then link = null
   // head is repositioned to point to node

   public int size() // Reads size of list
   {
      int count = 0;
      SuitorNode position = head; // Variable position of type SuitorNode will equal value at head; position points where head is pointing
      while(position != null) // While list is not empty/ended
      {
         count++; // increase number of entries detected
         position = position.link; // getLink will make position = link, leading to next entry in list
      }
      return count; // Display size.
   }

   public void outputList()
   {
      SuitorNode position = head; // Position points to same thing head points to

      while(position != null) // While list is not empty/ended
      {
         System.out.println(position.suitor); // Print suitor
         position = position.link; // Go to next entry
      }
   }

   public void deleteNode(int count)
   {
      int moveCount = count - 1;
      SuitorNode position = head;

      while(head != link) // not winning
      {
         moveCount = count;
         checkEnd(); // Checks for win before causing potential problem with 1 suitor left
         checkTwoNumbersLeft(moveCount); // Takes care of movement when two nodes are left
         checkEndNode(moveCount); // Checks when, for example, 2 nodes away

         if(moveCount == count) // If checkEndNode and checkTwoNumbersLeft fail
         {
            position = position.link; // Move for first time
            moveCount = moveCount - 1;
         }

         checkEnd();
         checkEndNode2(moveCount); // When one movement is made already, deletes end node after

         if(moveCount == moveCount - 1) // if checkEndNode2 fails
            position = position.link.link; // 2nd deletion
         count = moveCount;
      }

      isWinner();
   } // End method deleteNode()

   public void checkTwoNumbersLeft(int moveCount)
   {
      SuitorNode position;
      if(position.link.link == null) // example: 1 5
      {
         createLoop();
         position = position.link.link; // Deletes the 5
         moveCount = moveCount - 2;
      } // Used just in case only two numbers are present
   } // End method checkTwoNumbersLeft()

   public void checkEnd()
   {
      SuitorNode position;
      if(position.link == null) // If at end of list
      {
         createLoop(); // creates a loop if the initial number has no next value
         isWinner(); // If a 1 is used, the entire if statement will trigger
      } // if true, head == link which will fall out of while in deleteNode()
   } // End method checkEnd()

   public void isWinner()
   {
      SuitorNode link;
      SuitorNode position;
      if(position == position.link)
      {
         head = link;
         System.out.println("The winner is Suitor " + position + "!");
      }
   } // End method isWinner()

   public void checkEndNode2(int moveCount)
   {
      SuitorNode position;
      SuitorNode link;

      if(position.link.link == null) // 1 movement
      {
         position.link = null;
         createLoop();
         isWinner();
         moveCount = moveCount - 1;
      }
   } // End checkEndNode2()

   public void checkEndNode(int moveCount)
   {
      SuitorNode position;
      SuitorNode link;

      if(position.link.link.link == null) // no movements
      {
         position = position.link;
         position.link = null;
         createLoop();
         isWinner();
         moveCount = moveCount - 2;
      }
   } // End checkEndNode()

   public void createLoop()
   {
      SuitorNode position;
      SuitorNode link;

      if(link == null) // if at the end of the list
         link = head; // Sets link to point to where head points, AKA beginning of list
   } // End createLoop()
}

But when I do this, the variables link, position, and head always say they are not initialized unless I place them inside the method (which can mess up my code if I call the method while in the middle of the list).

My questions boil down to 1) How would I be able to convert the ints to strings in order to work with a linked list? and 2) Why are the variables in the program SuitorList requiring me to reinitialize them in every instance when I've tried placing them everywhere I could?

Body:
The issue is your peek function is defined as the wrong type

public String peak()
{
    if(!hasNext())
        throw new IllegalStateException();
    return position.suitor;
}

It's defined as returning a String

Instead it should be defined as suitor's type, an int

public int peak()
{
    if(!hasNext())
        throw new IllegalStateException();
    return position.suitor;
}

Same issue with public String next(), should instead be public int next()


问:
Laravel4 unable to create a directory although I gave correct permissions
Laravel4 unable to create a directory although I gave correct permissions.
FileException error happened, http://s28.postimg.org/xkor8srxp/2014_01_03_2_53_18.png.
I tried lots of permissions..

sudo chmod -R 777 storage

sudo chmod -R 707 storage

sudo chmod -R o+rwx storage

and I even restarted Apache server.
I have been googling 24 hours or so, and still can't figure out..
Here are the routes and view files.

```<code>// routes.php

Route::post('handle-form', function()
{
    $name = Input::file('book')->getClientOriginalName();
Input::file('book')->move('/storage/directory', $name);
return 'File was moved.';
});

// form2.blade.php
<form action="{{ url('handle-form') }}"
  method="POST"
  enctype="multipart/form-data">

<input type="file" name="book" />
<input type="submit">
</form>
</code>```

Currently what I did to the routes.php by following your help,

```<code>Route::post('handle-form', function()
{
$name = Input::file('book')->getClientOriginalName();
Input::file('book')->move(public_path().'/storage/directory', $name);
return 'File was moved.';
});
</code>```

and the permission I gave was sudo chmod -R 777 storage

答:
In my case, the problem was that I was using an environment variable which was not available at the time of making call so All I had to do was to change the variable I was using.

In short please check the path you are specifying.

Body:
Laravel4 unable to create a directory although I gave correct permissions.
FileException error happened, http://s28.postimg.org/xkor8srxp/2014_01_03_2_53_18.png.
I tried lots of permissions..

sudo chmod -R 777 storage

sudo chmod -R 707 storage

sudo chmod -R o+rwx storage

and I even restarted Apache server.
I have been googling 24 hours or so, and still can't figure out..
Here are the routes and view files.

// routes.php

Route::post('handle-form', function()
{
    $name = Input::file('book')->getClientOriginalName();
Input::file('book')->move('/storage/directory', $name);
return 'File was moved.';
});

// form2.blade.php
<form action="{{ url('handle-form') }}"
  method="POST"
  enctype="multipart/form-data">

<input type="file" name="book" />
<input type="submit">
</form>

Currently what I did to the routes.php by following your help,

Route::post('handle-form', function()
{
$name = Input::file('book')->getClientOriginalName();
Input::file('book')->move(public_path().'/storage/directory', $name);
return 'File was moved.';
});

and the permission I gave was sudo chmod -R 777 storage


问:
ILE RPG: Using QMHSNDPM, call stack entry not found
I am attempting to wade into the pool of MVC for RPG ILE.  So I have two modules VIEW, and MODEL, that are bound to my main program CNTRL.  I validate information entered in my VIEW module with calls to the MODEL module, and then pass back to the View any errors.  When I try to use the QHNSNDPM api, I see the error in the job log, followed by CALL STACK ENTRY NOT FOUND.  I tried to find theVIEW module on the call stack, and it is not there.  Not being super strong in DDS and the ILE, I am not sure how/what to do about this error.  Any Suggestions would be greatly appreciated!

The DCL-F DISPLAY WORKSTN; is in the VIEW module.

And now for a little code from the VIEW Module....

```<code>   dcl-pr SendMsg Extpgm('QMHSNDPM');
     MsgID char(7) const;
     MsgF  char(20) const;
     MsgData char(30) const;
     MsgDataLen  int(10) const;
     MsgType char(10) const;
     CallStackEnt char(10) const;
     CallStackCtr int(10) const;
     MsgKey char(4) const;
     Error  like(ErrorDS);

   end-pr;
  *******************************************************************

   dcl-proc VIEW_SetError EXPORT;
     dcl-pi *n;
        Msg int(3);
        MSGQ char(10);
     end-pi ;
     // The MSGQ parameter is from the PSDS *PROC
     // I tried having this defined in the view where the DDS file
     // is defined, and I have tried with it defined in the main CNTRL program

     Dcl-s MsgTxt char(30);

     if Msg=1;
        MsgTxt='Invalid Facility';
        AT1FAC=setAttr(*omit:'RI');
     elseif Msg=2;
         MsgTxt='Status must be O, C, or A!';
         AT1STAT=setAttr(*omit:'RI');
     elseif Msg=3;
         MsgTxt='Invalid Order Number';
         AT1ITEM=setAttr(*omit:'RI');
     elseif Msg=4;
         MsgTxt='Invalid Vendor Number';
         AT1VEND=setAttr(*omit:'RI');
     elseif Msg=5;
         MsgTxt='Invalid Pallet Number';
         AT1PLT=setAttr(*omit:'RI');
     endif;

      callp  SendMsg (*blanks: *blanks :
             MsgTxt : %size(MsgTxt):
            '*INFO': '*':
              0: *blanks: ErrorDS);
      // I have tried setting the CallStackEnt to * and C
      // And the CallStackCtr to 0,1,2
     write msgctl;

   end-proc ;
</code>```

and the DDS for DISPLAY....

```<code>     A                                      DSPSIZ(24 80 *DS3)
 A                                      CHGINPDFT(UL FE)
 A                                      PRINT
 A                                      HELP
 A                                      ALTHELP(CA01)
 A*                                     ALTPAGEUP(CF07)
 A*                                     ALTPAGEDWN(CF08)
 A                                      CF03(03)
 A                                      CF04(04)
 A                                      CF06(06)
 A                                      CF12(12)
  *------------------------------------------------------------------*
  * Screen 1 - Filter Criteria
  *------------------------------------------------------------------*
 A          R SCREEN1

 A                                      OVERLAY
 A                                      BLINK
 A                                      RTNCSRLOC(&REC1 &FLD1)
 A                                      CSRLOC(XROW1 XCOL1)
 A            XROW1          3S 0H
 A            XCOL1          3S 0H
 A            REC1          10A  H
 A            FLD1          10A  H
 A                                  1  2'SCN200-01'
 A                                      COLOR(BLU)
 A            COMPANY       40A  O  1 20DSPATR(HI)
 A            WSID          10A  O  1 62
 A                                  1 73DATE
 A                                      EDTCDE(Y)
 A                                  2  2SYSNAME
 A                                  2 23'Pallet Maintenance'
 A                                      COLOR(BLU)
 A                                  2 62USER
 A                                  2 73TIME
 A                                  5  4'Enter Facility to Search'
 A                                      COLOR(BLU)
 A                                  7  7'Facility:'
 A            DFAC1          2   B  7 21
 A                                      DSPATR(&AT1FAC)
 A            AT1FAC         1A  P
 A                                  7 24'+'
 A                                  8  2'Pallet Status:'
 A            DSTAT          1   B  8 21
 A                                      DSPATR(&AT1STAT)
 A            AT1STAT        1A  P
 A                                  8 24'(O=Open, C=Closed, or A=All)'
 A                                 10  4'Search by Item and/or Vendor:'
 A                                      COLOR(BLU)
 A                                 11 11'Item:'
 A            DITM1         15A  B 11 21
 A                                      DSPATR(&AT1ITEM)
 A            AT1ITEM        1A  P
 A                                 11 37'+  (Blank=All)'
 A                                 12  9'Vendor:'
 A            DVND1          5S 0B 12 21
 A                                      DSPATR(&AT1VEND)
 A            AT1VEND        1A  P
 A                                 12 28'+           (Blank=All)'
 A                                 15  7'Or By Pallet ID:'
 A                                      COLOR(BLU)
 A                                 16  9'Pallet:'
 A            DPLT1         11A  B 16 21
 A                                      DSPATR(&AT1PLT)
 A            AT1PLT         1A  P
 A                                 18  4'IF ALL SEARCH FIELDS LEFT BLANK, +
 A                                       ALL FACILITY RECORDS'
 A                                      COLOR(BLU)
 A                                 19  6 'DISPLAYED IN PALLET ID ORDER.'
 A                                      COLOR(BLU)
 A                                 23  2'F3=Exit'
 A                                      COLOR(BLU)
  *------------------------------------------------------------------*
  * Message Subfile
  *------------------------------------------------------------------*
 A          R MSGRCD                    TEXT('MSG SFL RECORD')
 A                                      SFL SFLMSGRCD(24)
 A            MSGKEY                    SFLMSGKEY
 A            PGMSGQ                    SFLPGMQ
  *------------------------------------------------------------------*
  * Message Subfile Control
  *------------------------------------------------------------------*
 A          R MSGCTL                    TEXT('MSG SFL CONTROL')
 A                                      OVERLAY SFLCTL(MSGRCD) SFLSIZ(10)
 A                                      SFLPAG(1) SFLDSPCTL SFLDSP SFLINZ
 A N98                                  SFLEND
 A            PGMSGQ                    SFLPGMQ
</code>```

Here is the CL that starts the process....its pretty basic, but we use a lot of overrides in our legacy code, so I thought it would help to start with a CL...

```<code>         PGM

         DCL        VAR(&COMPANY) TYPE(*CHAR) LEN(40) VALUE('BROWNFOX')
         CALL       PGM(CNTRL) PARM(&Company)
         ENDPGM
</code>```

By the way, the company bit is a relic to my testing.  I have added the Company retrieval from the service program.

And the CNTRL RPGLE...

```<code>       ctl-opt dftactgrp(*no) BNDDIR('MVC');
  *------------------------------------------------------------------*
  * Mainline processing
  *------------------------------------------------------------------*
   /define MODEL_PalletMaintenance
   /copy TEMPLATE/QCPYSRC,MODEL
   /undefine MODEL_PalletMaintenance
    /define VIEW_GetParms
   /copy TEMPLATE/QCPYSRC,VIEW
   /undefine VIEW_GetParms

   dcl-ds *N PSDS;
     PGMSGQ           *PROC;
     WSID CHAR(10) Pos(244);
     USER CHAR(10) Pos(254);
   end-ds;

   //dcl-s Exit ind;
   //dcl-s ErrorField char(30);
   dcl-s ErrorText char(30);
   dcl-s ErrorID   int(3);
   //dcl-ds Screen1DS likeDS(Screen1);
   dcl-s CurrentStep int(5);
   dcl-c StepExit 0;
   dcl-c StepPrep 1;
   dcl-c StepShowScreen1 2;
   dcl-c StepValidateScreen1 3;
   //dcl-c StepShowScreen2 0;

   dcl-pr cntrl EXTPGM  ;
   END-PR;
   //dcl-PROC cntrl;
    dcl-pi *n;
    END-PI;

   CurrentStep=StepPrep;

   DoU CurrentStep=StepExit;

     select;
       When CurrentStep=StepPrep;
         VIEW_Prep(Screen1DS);
         MODEL_Prep(Screen1DS);
         CurrentStep=StepShowScreen1;
       When CurrentStep=StepShowScreen1;
         if (VIEW_GetParms(Screen1DS));
           CurrentStep=StepValidateScreen1;
         else;
           CurrentStep=StepExit;
         ENDIF;
       When CurrentStep=StepValidateScreen1;
         ErrorID=MODEL_ValidateScreen1(Screen1DS);
         if (ErrorID<>0);
           VIEW_SetError(ErrorID:PGMSGQ);
           CurrentStep=StepShowScreen1;
         else;
           CurrentStep=StepExit;
         ENDIF;
       ENDSL;
   enddo;
   *INLR=*on;
   Return;
</code>```

And I guess if I've taken it this far, I might as well throw in the copy members

MODEL Copy

```<code>       /if defined(MODEL_PalletMaintenance)

   dcl-ds Screen1DS qualified;
     Company  char(40);
     Facility char(2);
     Status char(1);
     Item char(35);
     Vendor zoned(5:0);
     Pallet char(11);
   END-DS;

   DCL-PR MODEL_Prep;
     *n likeds(Screen1DS);
   END-PR;
   DCL-PR MODEL_ValidateScreen1 int(3);
     *n likeds(Screen1DS);
   END-PR;
   /endif
</code>```

And View....

```<code>  /if defined(VIEW_GetParms)

   dcl-ds VScreen1DS qualified;
     Company  char(40);
     Facility char(2);
     Status char(1);
     Item char(35);
     Vendor zoned(5:0);
     Pallet char(11);
   END-DS;

    DCL-PR VIEW_Prep;
     *n likeds(VScreen1DS);
   END-PR;

   DCL-PR VIEW_GetParms Ind;
     *n likeds(VScreen1DS);
   END-PR;

   DCL-PR screen1ResetIndicators;
   END-PR;

   DCL-PR ClearScreen1;
   END-PR;

   DCL-PR VIEW_SetError;
     *n int(3);
     *n char(10);
   END-PR;

   /endif
</code>```

答:
Troubleshoot QMHSNDPM:  Before calling QMHRMVPM' and after calling QMHSNDPM look at the messages for the interactive job (system request 3 then option 10 then f10 then f18) if you don't see your message something is wrong with the program sending the message.  If you do see the message press f1 with cursor on the message then press F9 to see where the message was delivered.

Probably you need a msgCallStack of 2 or 3 for your program or 4 or 5 if you want the message back at the command line.

I put in oldschool format to see the variable names.

```<code>call      'QMHSNDPM'
parm                    msgIdIN
parm                    msgLoc
parm                    msgRplDta
parm                    msgRplDtaLen
parm                    msgType
parm                    msgQueue
parm       3            msgCallStack
parm                    msgKey
parm                    msgErr
</code>```

That should shoot the message up from a procedure in the model back to the view.

For MVC style program in rpg interactive you start with the view then call down to the model which shoots the message back up to the view.  Maybe you have a controller that calls the view.

Body:
I am attempting to wade into the pool of MVC for RPG ILE.  So I have two modules VIEW, and MODEL, that are bound to my main program CNTRL.  I validate information entered in my VIEW module with calls to the MODEL module, and then pass back to the View any errors.  When I try to use the QHNSNDPM api, I see the error in the job log, followed by CALL STACK ENTRY NOT FOUND.  I tried to find theVIEW module on the call stack, and it is not there.  Not being super strong in DDS and the ILE, I am not sure how/what to do about this error.  Any Suggestions would be greatly appreciated!

The DCL-F DISPLAY WORKSTN; is in the VIEW module.

And now for a little code from the VIEW Module....

   dcl-pr SendMsg Extpgm('QMHSNDPM');
     MsgID char(7) const;
     MsgF  char(20) const;
     MsgData char(30) const;
     MsgDataLen  int(10) const;
     MsgType char(10) const;
     CallStackEnt char(10) const;
     CallStackCtr int(10) const;
     MsgKey char(4) const;
     Error  like(ErrorDS);

   end-pr;
  *******************************************************************

   dcl-proc VIEW_SetError EXPORT;
     dcl-pi *n;
        Msg int(3);
        MSGQ char(10);
     end-pi ;
     // The MSGQ parameter is from the PSDS *PROC
     // I tried having this defined in the view where the DDS file
     // is defined, and I have tried with it defined in the main CNTRL program

     Dcl-s MsgTxt char(30);

     if Msg=1;
        MsgTxt='Invalid Facility';
        AT1FAC=setAttr(*omit:'RI');
     elseif Msg=2;
         MsgTxt='Status must be O, C, or A!';
         AT1STAT=setAttr(*omit:'RI');
     elseif Msg=3;
         MsgTxt='Invalid Order Number';
         AT1ITEM=setAttr(*omit:'RI');
     elseif Msg=4;
         MsgTxt='Invalid Vendor Number';
         AT1VEND=setAttr(*omit:'RI');
     elseif Msg=5;
         MsgTxt='Invalid Pallet Number';
         AT1PLT=setAttr(*omit:'RI');
     endif;

      callp  SendMsg (*blanks: *blanks :
             MsgTxt : %size(MsgTxt):
            '*INFO': '*':
              0: *blanks: ErrorDS);
      // I have tried setting the CallStackEnt to * and C
      // And the CallStackCtr to 0,1,2
     write msgctl;

   end-proc ;

and the DDS for DISPLAY....

     A                                      DSPSIZ(24 80 *DS3)
 A                                      CHGINPDFT(UL FE)
 A                                      PRINT
 A                                      HELP
 A                                      ALTHELP(CA01)
 A*                                     ALTPAGEUP(CF07)
 A*                                     ALTPAGEDWN(CF08)
 A                                      CF03(03)
 A                                      CF04(04)
 A                                      CF06(06)
 A                                      CF12(12)
  *------------------------------------------------------------------*
  * Screen 1 - Filter Criteria
  *------------------------------------------------------------------*
 A          R SCREEN1

 A                                      OVERLAY
 A                                      BLINK
 A                                      RTNCSRLOC(&REC1 &FLD1)
 A                                      CSRLOC(XROW1 XCOL1)
 A            XROW1          3S 0H
 A            XCOL1          3S 0H
 A            REC1          10A  H
 A            FLD1          10A  H
 A                                  1  2'SCN200-01'
 A                                      COLOR(BLU)
 A            COMPANY       40A  O  1 20DSPATR(HI)
 A            WSID          10A  O  1 62
 A                                  1 73DATE
 A                                      EDTCDE(Y)
 A                                  2  2SYSNAME
 A                                  2 23'Pallet Maintenance'
 A                                      COLOR(BLU)
 A                                  2 62USER
 A                                  2 73TIME
 A                                  5  4'Enter Facility to Search'
 A                                      COLOR(BLU)
 A                                  7  7'Facility:'
 A            DFAC1          2   B  7 21
 A                                      DSPATR(&AT1FAC)
 A            AT1FAC         1A  P
 A                                  7 24'+'
 A                                  8  2'Pallet Status:'
 A            DSTAT          1   B  8 21
 A                                      DSPATR(&AT1STAT)
 A            AT1STAT        1A  P
 A                                  8 24'(O=Open, C=Closed, or A=All)'
 A                                 10  4'Search by Item and/or Vendor:'
 A                                      COLOR(BLU)
 A                                 11 11'Item:'
 A            DITM1         15A  B 11 21
 A                                      DSPATR(&AT1ITEM)
 A            AT1ITEM        1A  P
 A                                 11 37'+  (Blank=All)'
 A                                 12  9'Vendor:'
 A            DVND1          5S 0B 12 21
 A                                      DSPATR(&AT1VEND)
 A            AT1VEND        1A  P
 A                                 12 28'+           (Blank=All)'
 A                                 15  7'Or By Pallet ID:'
 A                                      COLOR(BLU)
 A                                 16  9'Pallet:'
 A            DPLT1         11A  B 16 21
 A                                      DSPATR(&AT1PLT)
 A            AT1PLT         1A  P
 A                                 18  4'IF ALL SEARCH FIELDS LEFT BLANK, +
 A                                       ALL FACILITY RECORDS'
 A                                      COLOR(BLU)
 A                                 19  6 'DISPLAYED IN PALLET ID ORDER.'
 A                                      COLOR(BLU)
 A                                 23  2'F3=Exit'
 A                                      COLOR(BLU)
  *------------------------------------------------------------------*
  * Message Subfile
  *------------------------------------------------------------------*
 A          R MSGRCD                    TEXT('MSG SFL RECORD')
 A                                      SFL SFLMSGRCD(24)
 A            MSGKEY                    SFLMSGKEY
 A            PGMSGQ                    SFLPGMQ
  *------------------------------------------------------------------*
  * Message Subfile Control
  *------------------------------------------------------------------*
 A          R MSGCTL                    TEXT('MSG SFL CONTROL')
 A                                      OVERLAY SFLCTL(MSGRCD) SFLSIZ(10)
 A                                      SFLPAG(1) SFLDSPCTL SFLDSP SFLINZ
 A N98                                  SFLEND
 A            PGMSGQ                    SFLPGMQ

Here is the CL that starts the process....its pretty basic, but we use a lot of overrides in our legacy code, so I thought it would help to start with a CL...

         PGM

         DCL        VAR(&COMPANY) TYPE(*CHAR) LEN(40) VALUE('BROWNFOX')
         CALL       PGM(CNTRL) PARM(&Company)
         ENDPGM

By the way, the company bit is a relic to my testing.  I have added the Company retrieval from the service program.

And the CNTRL RPGLE...

       ctl-opt dftactgrp(*no) BNDDIR('MVC');
  *------------------------------------------------------------------*
  * Mainline processing
  *------------------------------------------------------------------*
   /define MODEL_PalletMaintenance
   /copy TEMPLATE/QCPYSRC,MODEL
   /undefine MODEL_PalletMaintenance
    /define VIEW_GetParms
   /copy TEMPLATE/QCPYSRC,VIEW
   /undefine VIEW_GetParms

   dcl-ds *N PSDS;
     PGMSGQ           *PROC;
     WSID CHAR(10) Pos(244);
     USER CHAR(10) Pos(254);
   end-ds;

   //dcl-s Exit ind;
   //dcl-s ErrorField char(30);
   dcl-s ErrorText char(30);
   dcl-s ErrorID   int(3);
   //dcl-ds Screen1DS likeDS(Screen1);
   dcl-s CurrentStep int(5);
   dcl-c StepExit 0;
   dcl-c StepPrep 1;
   dcl-c StepShowScreen1 2;
   dcl-c StepValidateScreen1 3;
   //dcl-c StepShowScreen2 0;

   dcl-pr cntrl EXTPGM  ;
   END-PR;
   //dcl-PROC cntrl;
    dcl-pi *n;
    END-PI;

   CurrentStep=StepPrep;

   DoU CurrentStep=StepExit;

     select;
       When CurrentStep=StepPrep;
         VIEW_Prep(Screen1DS);
         MODEL_Prep(Screen1DS);
         CurrentStep=StepShowScreen1;
       When CurrentStep=StepShowScreen1;
         if (VIEW_GetParms(Screen1DS));
           CurrentStep=StepValidateScreen1;
         else;
           CurrentStep=StepExit;
         ENDIF;
       When CurrentStep=StepValidateScreen1;
         ErrorID=MODEL_ValidateScreen1(Screen1DS);
         if (ErrorID<>0);
           VIEW_SetError(ErrorID:PGMSGQ);
           CurrentStep=StepShowScreen1;
         else;
           CurrentStep=StepExit;
         ENDIF;
       ENDSL;
   enddo;
   *INLR=*on;
   Return;

And I guess if I've taken it this far, I might as well throw in the copy members

MODEL Copy

       /if defined(MODEL_PalletMaintenance)

   dcl-ds Screen1DS qualified;
     Company  char(40);
     Facility char(2);
     Status char(1);
     Item char(35);
     Vendor zoned(5:0);
     Pallet char(11);
   END-DS;

   DCL-PR MODEL_Prep;
     *n likeds(Screen1DS);
   END-PR;
   DCL-PR MODEL_ValidateScreen1 int(3);
     *n likeds(Screen1DS);
   END-PR;
   /endif

And View....

  /if defined(VIEW_GetParms)

   dcl-ds VScreen1DS qualified;
     Company  char(40);
     Facility char(2);
     Status char(1);
     Item char(35);
     Vendor zoned(5:0);
     Pallet char(11);
   END-DS;

    DCL-PR VIEW_Prep;
     *n likeds(VScreen1DS);
   END-PR;

   DCL-PR VIEW_GetParms Ind;
     *n likeds(VScreen1DS);
   END-PR;

   DCL-PR screen1ResetIndicators;
   END-PR;

   DCL-PR ClearScreen1;
   END-PR;

   DCL-PR VIEW_SetError;
     *n int(3);
     *n char(10);
   END-PR;

   /endif

Body:
Troubleshoot QMHSNDPM:  Before calling QMHRMVPM' and after calling QMHSNDPM look at the messages for the interactive job (system request 3 then option 10 then f10 then f18) if you don't see your message something is wrong with the program sending the message.  If you do see the message press f1 with cursor on the message then press F9 to see where the message was delivered.

Probably you need a msgCallStack of 2 or 3 for your program or 4 or 5 if you want the message back at the command line.

I put in oldschool format to see the variable names.

call      'QMHSNDPM'
parm                    msgIdIN
parm                    msgLoc
parm                    msgRplDta
parm                    msgRplDtaLen
parm                    msgType
parm                    msgQueue
parm       3            msgCallStack
parm                    msgKey
parm                    msgErr

That should shoot the message up from a procedure in the model back to the view.

For MVC style program in rpg interactive you start with the view then call down to the model which shoots the message back up to the view.  Maybe you have a controller that calls the view.


问:
parse xml files with python 3
Let's assume that i have couple of xml files.
Assume that the first file is the base and the next files are the overrides (like update to the base file).
I want to write a program that get lists of files (updates) and create a final xml with all the data.
I succeed to read each file but i don't know how to combine them together.

The original xml:

```<code><Base>
<Module ID = "Module1"
    Prop1 = "A"
    Prop2 = "B"
    Prop3 = "C"
/>
<!-- XML comment -->
<Module ID = "Module2"
    Prop1 = "D"
    Prop2 = "E"
    Prop3 = "F"
/>
</Base>
</code>```

An update:

```<code><!-- XML comment -->
<Override>
<Module ID = "Module1"
    Prop2 = "B_ov"
    Prop4 = "ZZ"
/>
<!-- XML comment -->
<Module ID = "Module2"
    Prop1 = "D_ov"
    Prop5 = "F"
/>
</Override>
</code>```

Final xml file should look like:

```<code> <!-- XML comment -->
<final>
<Module ID = "Module1"
    Prop1 = "A"
    Prop2 = "B_ov"
    Prop3 = "C"
    Prop4 = "ZZ"
/>
<!-- XML comment -->
<Module ID = "Module2"
    Prop1 = "D_ov"
    Prop2 = "E"
    Prop3 = "F"
    Prop5 = "F"
/>
</final>
</code>```

The code:

```<code>from argparse import ArgumentParser
from xml.etree import ElementTree

def main():
parser = ArgumentParser()
parser.add_argument('xml', nargs='+')

a=parse_xml("Base.xml")
print (a)

b= parse_xml("Override.xml")
print (b)

def parse_xml(path):
    return {m.attrib.pop('ID'): m.attrib for m in ElementTree.parse(path).findall('Module')}

if __name__ == '__main__':
    main()
</code>```

答:
Extended solution (without  items):

```<code>import xml.etree.ElementTree as ET

base_tree = ET.parse('Base.xml')
base_root = base_tree.getroot()
override = ET.parse('Override.xml').getroot()

base_root.tag = 'final'   # set new `root` tag

for m in base_root.findall('Module[@ID]'):

    # finding the `overridden` Module element with respective `ID`
    repl_el = override.find('Module[@ID="{}"]'.format(m.get('ID')))
    base_attrs = dict(m.items())
    base_attrs.update(repl_el.items())
    for k,v in base_attrs.items():
        m.set(k, v)

print(base_tree.write('output.xml', encoding='unicode'))
</code>```

The final output.xml contents:

```<code><final>
<Module ID="Module1" Prop1="A" Prop2="B_ov" Prop3="C" Prop4="ZZ" />

<Module ID="Module2" Prop1="D_ov" Prop2="E" Prop3="F" Prop5="F" />
</final>
</code>```

Title: parse xml files with python 3

Body:
Let's assume that i have couple of xml files.
Assume that the first file is the base and the next files are the overrides (like update to the base file).
I want to write a program that get lists of files (updates) and create a final xml with all the data.
I succeed to read each file but i don't know how to combine them together.

The original xml:

<Base>
<Module ID = "Module1"
    Prop1 = "A"
    Prop2 = "B"
    Prop3 = "C"
/>

<Module ID = "Module2"
    Prop1 = "D"
    Prop2 = "E"
    Prop3 = "F"
/>
</Base>

An update:

<Override>
<Module ID = "Module1"
    Prop2 = "B_ov"
    Prop4 = "ZZ"
/>

<Module ID = "Module2"
    Prop1 = "D_ov"
    Prop5 = "F"
/>
</Override>

Final xml file should look like:

<final>
<Module ID = "Module1"
    Prop1 = "A"
    Prop2 = "B_ov"
    Prop3 = "C"
    Prop4 = "ZZ"
/>

<Module ID = "Module2"
    Prop1 = "D_ov"
    Prop2 = "E"
    Prop3 = "F"
    Prop5 = "F"
/>
</final>

The code:

from argparse import ArgumentParser
from xml.etree import ElementTree

def main():
parser = ArgumentParser()
parser.add_argument('xml', nargs='+')

a=parse_xml("Base.xml")
print (a)

b= parse_xml("Override.xml")
print (b)

def parse_xml(path):
    return {m.attrib.pop('ID'): m.attrib for m in ElementTree.parse(path).findall('Module')}

if __name__ == '__main__':
    main()

Body:
Extended solution (without <!-- XML comment --> items):

import xml.etree.ElementTree as ET

base_tree = ET.parse('Base.xml')
base_root = base_tree.getroot()
override = ET.parse('Override.xml').getroot()

base_root.tag = 'final'   # set new `root` tag

for m in base_root.findall('Module[@ID]'):

    # finding the `overridden` Module element with respective `ID`
    repl_el = override.find('Module[@ID="{}"]'.format(m.get('ID')))
    base_attrs = dict(m.items())
    base_attrs.update(repl_el.items())
    for k,v in base_attrs.items():
        m.set(k, v)

print(base_tree.write('output.xml', encoding='unicode'))

The final output.xml contents:

<final>
<Module ID="Module1" Prop1="A" Prop2="B_ov" Prop3="C" Prop4="ZZ" />

<Module ID="Module2" Prop1="D_ov" Prop2="E" Prop3="F" Prop5="F" />
</final>