1. Paweł Kasperek
  2. PowerBuilder
  3. Tuesday, 5 November 2024 08:39 AM UTC

Hi,

 

How I can write superscript ex. x² in Datawindow UI components? Is possible to set superscript in any visual object in PowerBuilder? 

 

Regards,

Pawel

Andreas Mykonios Accepted Answer Pending Moderation
  1. Tuesday, 5 November 2024 12:34 PM UTC
  2. PowerBuilder
  3. # 1

Hi.

You can display superscript in a column by using rtf style in edit properties of that column. Unfortunately the toolbar presented when editing a column with that style is limited! If you need the user to type data with superscript, I guess you need to request some enhancement.

Example showing some text with superscript.

Use the following sql to create a datawindow (hope the database you are using supports dummy or dual):

SELECT Cast('{\rtf1\ansi\pard ax{\super 3}+bx{\super 2}+cx=0.\par}' AS VARCHAR(2000)) AS a1
  FROM dummy; 

// or if your database supports dual:

SELECT Cast('{\rtf1\ansi\pard ax{\super 3}+bx{\super 2}+cx=0.\par}' AS VARCHAR(2000)) AS a1
  FROM dual; 

Set the column's (a1) edit style:

Retrieve the datawindow. You should see:

Explanation:

The rtf real commands are:

{\rtf1\ansi\pard ax{\super 3}+bx{\super 2}+cx=0.\par}

{\super [some text]}: shows text in superscript.

\pard is used to reset paragraph formatting.

\par will create a new line. If you omit it then you will have one line.

Of course all those require you understand how rtf format works and what "commands" it supports. You can google search to find more specific information. You can also check the following link which has some information about rtf: Application interchange file formats - tutorial.

One final point: rtf will require more space to be stored in a database column.

Andreas.

Comment
  1. Paweł Kasperek
  2. Wednesday, 13 November 2024 11:35 AM UTC
Hi,

Thank you ALL for your answers and help. The simple solution with copy char from Windows Character Map tool works.



Regards,

Pawel
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 5 November 2024 14:31 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Pawel -

In addition to Andreas' suggestion, there may be another way.

If the font that is being used contains the needed character(s), you can type them (but only if you know the super-secret handshake). Use of the Windows Character Map utility is very helpful. As you'll soon see, it is not a user-friendly process.

For example, if Tahoma is being used, Character Map shows that a superscript 2 character maps to a Unicode value of 0x00B2:

In the lower-right corner, you see the decimal equivalent of 0x00B2 (0178). If you hold down the Alt key and type 0178 on the numeric keypad, Windows will translate this keypress sequence into the Unicode character 0x00B2.

Example: a²+b²=c²

is keyed as follows: a,Alt+0178,+,b,Alt+0178,=,c,Alt+0178

If this is data that will be contained in a column and ultimately stored in a database, then there may be additional considerations. For example, in SQL Server, strings using single-byte/character encoding are defined using the varchar data type, but Unicode strings use the nvarchar data type. The code page used by the database may also affect character encoding. I call these additional points to your attention in case you are not aware of them.

HTH. Best regards, John

Comment
  1. Andreas Mykonios
  2. Tuesday, 5 November 2024 15:05 PM UTC
You are right John. This is an easy way to use those characters. To easy find superscript or subscript numbers, just check advanced, and in group by, select Unicode Subrange. This will bring a window where you can find a subrange named: "Super/Subscript". To facilitate the process.

Andreas.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.