You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Nisheeth

Beginner

  • "Nisheeth" is male
  • "Nisheeth" started this thread

Posts: 8

Date of registration: Oct 27th 2010

Location: India

Occupation: Researcher

  • Send private message

1

Tuesday, December 28th 2010, 3:27pm

vbProperCase problem

Hi Friends

Look at the following code

Jabaco Source

1
2
3
4
5
Public Sub Command1_Click()
msgbox(StrConv(Text1.Text, vbUpperCase))   ' works fine
msgbox(StrConv(Text1.Text, vbLowerCase))   'works fine
msgbox(StrConv(Text1.Text, vbProperCase))   'does not work ?????????????
End Sub


Can anybody explain it to me why??????????

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Tuesday, December 28th 2010, 10:59pm

If you look this up in the Framework, you find in Strings.java:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
private static String PCase(String String1) {
        return (String1);
}

private static String XCase(String String1) {
        return (String1);
}

public static String StrConv(String String1, VBStrConv ConvMet) {
                switch ( ConvMet.intValue() ) {
                        case ( 1 ): {   return (UCase(String1));        } // vbUpperCase
                        case ( 2 ): {   return (LCase(String1));        } //  vbLowerCase
                        case ( 3 ): {   return (PCase(String1));        } //  vbProperCase // NOT IMPLEMENTED
                        case ( 4 ): {   return (XCase(String1));        } //  vbWide    // NOT IMPLEMENTED
                        case ( 8 ): {   return (XCase(String1));        } //  vbNarrow // NOT IMPLEMENTED
                        case ( 16 ): {  return (XCase(String1));        } //  vbKatakana // NOT IMPLEMENTED
                        case ( 32 ): {  return (XCase(String1));        } //  vbHiragana // NOT IMPLEMENTED
                        case ( 64 ): {  return (XCase(String1));        } //  vbUnicode // NOT IMPLEMENTED
                        case ( 128 ): { return (XCase(String1));        } //  vbFromUnicode // NOT IMPLEMENTED
                }
                return (String1);
}


So, this feature needs a volunteer to implement it.

Greetings
A1880

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

3

Wednesday, December 29th 2010, 1:59am

So, this feature needs a volunteer to implement it.


Done.

Current implementation is

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public static String PCase(String String1) {
        String String2 = "";
        boolean lastWasLetter = false;
        for (int i=0; i<=String1.length()-1; i++) {
                Character ch = String1.charAt(i);
                if (Character.isLetterOrDigit(ch)) {
                        if (Character.isDigit(ch)) {
                                String2 = String2.concat(ch.toString());
                        } else if (lastWasLetter) {
                                String2 = String2.concat(ch.toString().toLowerCase());
                                lastWasLetter = true;
                        } else {
                                String2 = String2.concat(ch.toString().toUpperCase());
                                lastWasLetter = true;
                        }
                } else {
                        String2 = String2.concat(ch.toString());
                        lastWasLetter = false;
                }
        }
        return (String2); 
}


The last change was, that I made it to public, so that it is possible to use it direct as PCase(String) like it is possible with UCase and LCase.
If you think it would be better to call it only over StrConv, then I will change it back to private.

Greatings
theuserbl

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

4

Wednesday, December 29th 2010, 11:08am

Having PCase() for direct calls is a good idea.
Thanks for the quick fix!

How can we get the updated framework for download?

Greetings

A1880

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

5

Wednesday, December 29th 2010, 12:01pm

How can we get the updated framework for download?


From
http://www.file-upload.net/download-3086647/Jabaco.jar.html

But it is only a minor change. Only the Systems-class was chenged.

And there is a little problem. Currently I have compiled Systems.java with the options "-source 1.5 -target 1.5", because with "-source 1.4 -target 1.4.2" there comes for Systems.java the following errors:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
VBA\Strings.java:205: incompatible types
found   : char
required: java.lang.Character
                        Character ch = String1.charAt(i);
                                                     ^
VBA\Strings.java:206: cannot find symbol
symbol  : method isLetterOrDigit(java.lang.Character)
location: class java.lang.Character
                        if (Character.isLetterOrDigit(ch)) {
                                     ^
VBA\Strings.java:207: cannot find symbol
symbol  : method isDigit(java.lang.Character)
location: class java.lang.Character
                                if (Character.isDigit(ch)) {
                                             ^
3 errors


So sadly with my last code, it is no longer 1.4-compatible. :(
I will look at a solution.

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

6

Wednesday, December 29th 2010, 12:05pm

Oh, and by the way:
Here is the String I used, to test PCase:

Jabaco Source

1
s = "Dieses ist ein kleiner Test. [dsf],{ff]sd{sf/fd[&feg§sdgbföfsd65ghfÜrgreh fhth 456fgfg"

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

7

Wednesday, December 29th 2010, 12:42pm

Ok, here is now the actual version:
http://www.file-upload.net/download-3086723/Jabaco.jar.html

And it is again compiled with the Java 1.4 options.

Here the little changes, to make it work with 1.4:
http://code.google.com/p/jabacoframework/source/detail?r=80#

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

8

Wednesday, December 29th 2010, 1:55pm

Great! That works quite well.

Jabaco Source

1
2
3
4
Private Sub pCaseTest
   Debug.Print PCase("ein großer übler mit einem kleinen ärger $%&*+# ")
   Debug.Print StrConv("ein großer übler mit einem kleinen ärger $%&*+# ", vbProperCase)
End Sub


Thanks!

A1880

Rate this thread
WoltLab Burning Board