Thread and FormEx libraries with 6.42

Discussion in 'Beta Versions' started by agraham, Aug 27, 2008.

  1. agraham

    agraham Expert Licensed User

    To use the Threading library with the latest version you will need to change the name of the thread Sub by prefixing the Sub name with "_ModuleName_"
    Code:
    Thread.Start("_Main_ThreadCode")
    To use Threading with a FormEx you will also need to change the name of the Thread.
    Code:
    FormEx1.EnableThreading("_Main_Thread1", B4PObject(1))
    ...
    Thread1.Start(
    "_Main_ThreadCode")
    I am pondering whether to change the code of both libraries so that you can do
    Code:
    Thread1.Start("Main.ThreadCode")
    Any opinions?

    EDIT:- Having typoed the title of this threead I can find no way of editing it! Is it possible?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Fixed.

    I think that the last option is preferable.
    You can use this code in your library (same as the one used by the compiler):
    Code:
    subName = "_" + subName.Replace(".""_");
     
  3. agraham

    agraham Expert Licensed User

    It seems to need
    Code:
    "__" + ThreadSub.ToLower(cul).Replace(".""_")
    Why two underscores?

    While I am changing it I think I might complicate it a bit :) and make it compatible with earlier versions
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    The parser now adds one and the optimized compiler adds another one (the compiler wasn't changed).

    I agree, it should be backwards compatible. You can use B4P method:
    Code:
    ThreadSub = "_" + Other.FixRuntimeControlName(ThreadSub,"main");
    The code for FixRuntimeControl is:
    Code:
    public static string FixRuntimeControlName(string controlName, string moduleName)
            {
                controlName = controlName.ToLower(b4p.cul);
                
    if (controlName.IndexOf(".") > -1)
                    
    return "_" + controlName.Replace(".""_");
                
    else
                    
    return "_" + moduleName + "_" + controlName;
            
    }
     
  5. agraham

    agraham Expert Licensed User

    Why moduleName for pre-6.42? I'm using this which seems to work for both 6.30 and 6.42
    Code:
    private String b4pname(String name)
    {
        
    if (name.IndexOf('.') >= 0)
        {
            
    return "__" + name.ToLower(cul).Replace(".""_");
        
    }
        return "_" + name.ToLower(cul);
     }
    EDIT :- I've looked at Other.cs and seen what that code is meant to do (add the default module name if none specified), but it is not applicable here as pre 6.42 only the Sub name is in htSubs with no qualification.
     
    Last edited: Aug 27, 2008
  6. Erel

    Erel Administrator Staff Member Licensed User

    I meant that it will be compatible with existing code running under the new version.
    That way users will not have to add the "main." prefix to their code.
     
  7. agraham

    agraham Expert Licensed User

    For "compatible" I meant that the library would optimise compile and run with earlier versions of B4ppc. It would seem that we can't have both sorts of compatibility :( or maybe we can if I look for two leading underscores in htSubs - I'll think about it :confused:
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Most users will eventually use the new version.
    Other users can just keep the older versions of your libraries.
     
  9. agraham

    agraham Expert Licensed User

    Compatibility all round! - dead easy :)
    Code:
    IEnumerator ienum = htSubs.Keys.GetEnumerator();
             enum.MoveNext();
             
    String str = (String)ienum.Current;
             
    if (str.Substring(02) == "__")
                 modules = 
    true;
            ....
            
    private String b4pname(String name)
            {
                
    if (name.IndexOf('.') >= 0)
                {
                    // >
    6.42  & module.name
                    
    return "__" + name.ToLower(cul).Replace(".""_");
                
    }
                if (modules)
                {
                    // >6.42  & name
                    return "__" + "main_" + name.ToLower(cul);
                }
                // 6.30 or earlier
                return "_" + name.ToLower(cul);
            }
     
  10. agraham

    agraham Expert Licensed User

    If anyone is following this thread I will post the modified Threading and FormEx libraries once the release of the stable version is close so that I am sure they will work OK. In the mean time the workaround in post #1 can be used.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice