Java equivalent to VBScript functions/operators
I need to re-write some VBScript code to j2me code. I'd like to know if there is an equivalent to the following VBScript functions in j2me.
Function Chr(): The Chr function converts an ANSI character code value to a character. I think I can just use char x = (char) myCharValue. correct?
Function Asc(): The Asc function returns the ANSI character code value for the first character in a string.
Operator Xor: The Xor operator can be used a "bitwise operator" to make a bit-by-bit comparison of two integers. If both bits are the same in the comparison (both are 0's or 1's), then a 0 is returned. Otherwise, a 1 is returned. For example: Xor performs a bitwise comparison on the 3 (in binary 011) and the 5 (in binary 101), and returns a 6 (in binary 110).
Function Chr(): The Chr function converts an
ANSI character code value to a character. I think I
can just use char x = (char) myCharValue. correct?Yes
Function Asc(): The Asc function returns the
ANSI character code value for the first character in
a string.
String abc = "ABC";
char firstchar = abc.charAt(0);
Operator Xor: The Xor operator can be used a
"bitwise operator" to make a bit-by-bit comparison of
two integers. If both bits are the same in the
comparison (both are 0's or 1's), then a 0 is
returned. Otherwise, a 1 is returned. For example:
Xor performs a bitwise comparison on the 3 (in binary
011) and the 5 (in binary 101), and returns a 6 (in
binary 110).A simple google search will give you that "^" is an xor.
Similar Messages
-
Does flex can call vbscript function ?
i am not sure does flex or action script can call vbscript function .
how can i get detail information . thank you!Adobe does not provide such a capability. Folks have created ways to call
Java I believe, and ExternalInterface will call JavaScript. And you can use
sockets. And NativeProcess from AIR apps. -
Equivalent of to_date function in Ms SQL and using it in Evaluate function
Hi,
I am trying to find out a function in MS SQL which is equivalent to to_date function in oracle. Please find below the advanced filter i am trying to use in OBIEE.
Evaluate('to_date(%1,%2)' as date ,SUBSTRING(TIMES.CALENDAR_MONTH_NAME FROM 1 FOR 3)||'-'||cast(TIMES.CALENDAR_YEAR as char(4)),'MON-YYYY')>=Evaluate('to_date(%1,%2)' as date,'@{pv_mth}'||'@{pv_yr}','MON-YYYY') and Evaluate('to_date(%1,%2)' as date ,SUBSTRING(TIMES.CALENDAR_MONTH_NAME FROM 1 FOR 3)||'-'||cast(TIMES.CALENDAR_YEAR as char(4)),'MON-YYYY') <=timestampadd(sql_tsi_month,4,Evaluate('to_date(%1,%2)' as date,'@{pv_mth}'||'@{pv_yr}','MON-YYYY'))
The statement above works fines with oracle DB with to_date function. The same statement throws an error with MS SQL since to_date is not a built in function.
With MS SQL I tried with CAST, not sure how to pass parameters %1 and %2.
Please help me how to use Evaluate function and passing parameters along with to_date funtion in MS SQL.
Regards!
RRHi,
please refer to this thread for useful information on using to_char and to_date functions of oracle in MS SQL server:
http://database.ittoolbox.com/groups/technical-functional/sql-server-l/how-to-write-to-to_char-and-to_date-sql-server-351831
Hope this helps.
Thanks,
-Amith. -
Problem Calling a Java class from PLSQL function
We are calling a Java class through oracle function as
FUNCTION CalculateAMW (contributorid IN Number,
fromdate IN Date,OHorAnncoverage in Number,
OHAnncoverage in Number,
AppStatus in Number,
Status in Number)
RETURN Number
AS LANGUAGE JAVA
NAME 'AMWCalculations.calculateAMW
(long,java.sql.Timestamp,long,long,long,long) return double';
on execution of this function the sql prompt for the 1st time it is giving the output
but
if reexecute it is throwing and error ORA - 932 : Inconsistent
datatypes.
Recompiling the java class then it works for the 1st time and the next
time
we execute it throws error as explained above.
What could be the problem.
Thanks
Nanda Kishoreany idea???Yes, you are in the wrong forum, this is a Java forum, you have an ASP question, so i suggest you visit an ASP forum/site
-
Equivalent of ValueList function in SQL
Hi,
Is there an equivalent of valueList function in SQL? Here's
what I am trying to do:
Suppose I have the following table:
Name -- Color
John -- Green
John -- Red
Mike -- White
I want to do a query such that the colors are aggregated as a
list. So the result would be:
Name -- Color List
John -- Green, Red
Mike -- White
The only way I could think of doing this is to loop through
each name in the table and doing ValueList in each loop. Is there a
better way?
Thanks.
Min> I want to do a query such that the colors are aggregated
as a list.
If it _must_ be done in sql, there are some database options.
Such as the one mentioned above. There are also some interesting
approaches using xml path and cross apply with MS SQL 2005. I do
not know about other databases.
http://databases.aspfaq.com/general/how-do-i-concatenate-strings-from-a-column-into-a-sing le-row.html
Bear in mind there are some performance implications with all
of the methods. For example, a udf would execute once for each
name. So the more records, the greater the impact.
Another possibility is to use cfoutput's group attribute to
create a list for each name. Assuming that is feasible .. -
What is the non-recursive stack based equivalent of this function?
what is the non-recursive stack based equivalent of this function?
static void _try (int n)
int i; if (n==4) print(); else for (i=0; i<4; i++) if (is_free(i,n)) {
x[n] = i;
_try(n+1);
}It goes infinite no output. Thanks though.
public class CopyOfDamen { // x[i] = x coordinate of queen in row i.
static int N = 4; static Stack stack = new Stack(); static int [] x = new int[8]; public static void main(String [] par) { _try(); }
// prints field
static void print ()
int i,j;
System.out.print ("+----------------+\n");
for (i=0; i<8; i++) {
System.out.print ("|");
for (j=0; j<8; j++)
if (j==x) System.out.print ("<>"); else System.out.print (" ");
System.out.print ("|\n");
System.out.print ("+----------------+\n\n");
// tests, whether (ix, iy) is beaten by queens 0...(iy-1)
static boolean is_free (int ix, int iy)
int i;
for (i=0; i<iy; i++)
if ((x[i]==ix) || (Math.abs(x[i]-ix)==Math.abs(i-iy))) return false;
return true;
// tries to place queen n on row n
static void _try () {
int i = 0, n = 0;
call:
for(;;) { // forever
if (n == N) {
print();
} else {
for (;i < N; i++) {
if (is_free(i,n)) {
x[n] = i;
System.out.print(x[n] + " ");
n++;
stack.push(i);
i = 0;
continue call; // call _try (but first save state and initiate new state)
} System.out.println();
// _try returns (check termination criterion and restore state)
n--;
if (n < 0) break; // terminate
i = stack.pop();
} class Stack {
int StackSize = 32, top = 0; int [] stack = new int[StackSize]; public Stack() {} void push(int x) { if (top < StackSize) stack[top++] = x; } int pop() { if (top >= 1) return stack[--top]; return -1; } -
Calling java class from abap function moduile
Is it possible to call java class from function module.
i am a java guy. my need is to call a java class from a function module in the backend. which in turn performs certain functions.
i would be highly obliged if someone could let me know if this is possible.
regards
Srikumar VHi Srikumar ,
you can call a java webservice in ABAP .
u can call the webservice and via that u can trigger the java class..
Regards
Renu -
Replace the wait with java embedding thread.sleep() function
Hi,
How to replace the wait with java embedding thread.sleep() function. Can anyone help.
Thanks.drag and drop the java embedding component
include the following code in it.
try{
Thread.sleep(60000);
}catch(Exception e)
--Prasanna -
Equivalent Class for Function Module for VIEW_MAINTENANCE_CALL
Hi Gurus,
Can any one let me know
Equivalent Class for Function Module for VIEW_MAINTENANCE_CALL
Thanks in aTry Class:
CL_TABLECONTROL
Or do check if this class is of any use:
CL_SALV_FULLSCREEN_ADAPTER -
Can i write java code in JavaScript function
I want to call JavaBeans within JavaScript function. Can I do it?
I have a button in JSP . When the button be clicked,the data be inputted will be checked by JavaScript function. If check is ok, then call a Bean's function to write the data to database.
Please Help!well indeed u can write java code in javascript functions. But probably it will not work the way u want it to.
when u say that u click a button, it means that some client side action is performed. Now if u wud require a java bean to be called then it means that the server needs to be contacted for the same, and if that has to be done, necessarily the form needs to be submitted.
U can populate values from a java bean and then the same can be made available to a javascript variable / function when the page is loaded rather than, when the button is clicked.
What u can do is on click of button u can process [display / calulate..etc ] the information which has already been got by the java bean.
Kris -
Calling java method from c function
Hi,
I have been through some forums and tutorials, but nothing helps me yet.
Here's my problem : I want to access java funtion from c function.
<code java>
public class MyClass {
public int oneMethod() {
return 5;
</code java>
<code c++>
void main(int argc, char *argv[]) {
// creation of JVM -> no problem
cls = (env)->FindClass("MyClass");
if (cls != 0) {
// it finds the class
mid = (env)->GetMethodID(cls, "oneMethod", "()I");
if (mid != 0) {
// it finds the method
intReturn = (env)->CallIntMethod(cls, mid);
printf("Result of oneMethod: %d \n", initReturn);
</code c++>
the initReturn gives me 0, and not 5. So what do you think the mistake is ?
Should I pass by the GetClassObject() funtion, but in this case, what object would I pass in reference since I'm using a call from c to java.
Thanks a lot for your response, and Happy new Year to all the comunity.1. You are - apparently - trying to call a method of a java object.
2. But you are instead making the call on a class.
3. You can do one of the following:
o Pass a reference to the object as you call C.
o Call some other java method (maybe static) that gets you a reference to a java object.
o Use JNI to call a java constructor to create a java object.
o Change your code to get the class object and call a static method. -
Calling java APIs from a function module
Hi,
Can someone tell me whether it is possible to call Java APIs from a function module in SAP system?
Thanks in advance,
VineethaHi,
I guess you have changed the properties of screen only.
I assume you have made a Ztransaction Code.
When you define a transaction code, you need to specify a screen number for radio option program and screen and you need to specify a screen and not subscreen.( I think so!!)
You changed only the code without changing the transaction code properties.
Therefore, i think u r getting a dump.
If you want to call your subscreen, call it in some screen and then call that screen using your transaction code properties.
To include a subscreen screen in the subscreen area of the main screen and call its PBO flow logic, use the following statement in the PBO event of the main screen:
PROCESS BEFORE OUTPUT.
CALL SUBSCREEN <area> INCLUDING <prog> <dynp>.
To call the PAI flow logic of the subscreen screen, use the following statement in the PAI flow logic of the main screen:
PROCESS AFTER INPUT.
CALL SUBSCREEN <area>.
Refer:
http://help.sap.com/saphelp_webas630/helpdata/en/9f/dbabfe35c111d1829f0000e829fbfe/content.htm
Regards,
Tanveer.
Please mark helpful answers.
Message was edited by: Tanveer Shaikh
Message was edited by: Tanveer Shaikh -
Implement the Java equivalent of onMouseOver JavaScript function
I am translating a web app written in JavaScript into Java applet. I am adding Line and Rectangle objects to the applets. How can I implement the Javascript equivalent of onMouseOver and onMouseOut functions to the objects in the applet?
Heres an example. The lines dont work though.
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.ArrayList;
public class RolloverTest{
public static void main(String[] args){
new RolloverTest();
public RolloverTest(){
shapes = new ArrayList(5);
Rectangle rect1 = new Rectangle(10, 10, 40, 40);
shapes.add(new HotShape(rect1, mouseOff));
Rectangle rect2 = new Rectangle(40, 70, 40, 40);
shapes.add(new HotShape(rect2, mouseOff));
Line2D line1 = new Line2D.Double(100, 100, 200, 200);
shapes.add(new HotShape(line1, mouseOff));
Line2D line2 = new Line2D.Double(10, 300, 300, 10);
shapes.add(new HotShape(line2, mouseOff));
Ellipse2D oval1 = new Ellipse2D.Double(300, 100, 60, 60);
shapes.add(new HotShape(oval1, mouseOff));
hotPiece = (HotShape)shapes.get(0);
drawingBoard = new DrawingBoard(this);
frame = new JFrame("Rollover Test");
frame.setContentPane(drawingBoard);
frame.setSize(500, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public class DrawingBoard extends JPanel implements MouseMotionListener{
public DrawingBoard(RolloverTest rt){
this.rt = rt;
this.setBackground(Color.WHITE);
this.addMouseMotionListener(this);
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D gfx = (Graphics2D)g;
gfx.setStroke(new BasicStroke(5));
for(int i = 0; i < rt.shapes.size(); i++){
HotShape shape = (HotShape)rt.shapes.get(i);
gfx.setColor(shape.color);
gfx.draw(shape.shape);
public void mouseDragged(MouseEvent evt){}
public void mouseMoved(MouseEvent evt){
for(int i = 0; i < rt.shapes.size(); i++){
HotShape shape = (HotShape)rt.shapes.get(i);
if(shape.shape.contains((double)evt.getX(), (double)evt.getY())){
rt.hotPiece.color = rt.mouseOff;
rt.hotPiece = shape;
shape.color = rt.mouseOn;
this.repaint();
RolloverTest rt;
public class HotShape{
public HotShape(Shape shape, Color color){
this.shape = shape;
this.color = color;
Shape shape;
Color color;
JFrame frame;
DrawingBoard drawingBoard;
ArrayList shapes;
HotShape hotPiece;
Color mouseOff = Color.BLUE;
Color mouseOn = Color.RED;
}Message was edited by:
TuringPest
Even using a bigger Stroke the lines wont return true for contains(). So you will have to find a different approach for lines. -
Java Equivalent Function to Obfuscation DES3 Procedures
I've read all of the notes and reports that I could find on both OTN and MetaLink, but I can't find a solution anywhere. Just hints, particularly in Note 232000.1 and Note 225214.1. I've been trying all of the variations that I can think of in test code with no success. I've also searched the net extensively.
What I need is a code sample IN JAVA that provides equivalent functionality to the des3encrypt and des3decrypt procedures using raw values in the obfuscation toolkit.
We have a number of huge databases in which we would like to use the obfuscation toolkit with DES3 3-key (192-bit) keys to manage encrypting
confidential data. We need to be able to read this data from Java applications. Those applications must be able to decrypt the values encrypted using the toolkit. We must also be able to do the reverse, encrypt data in Java, store the encrypted values, the decrypt and access the data in PL/SQL using the toolkit.
I've searched high and low, but I cannot find sample code anywhere for performing this functionality in an equivalent fashion.
Thanks!
Mark Scarton
[email protected]Hi Mark,
I encountered a similar challenge, were you able to figure out the solution for this problem?
Thanks,
Srikanth -
What is the Java equivalent of Visual BAsic ASC() and MID() functions
Hello all! I just would like to ask if you have any idea on how to convert the VB ASC() and MID() functions into java. Where:
1. ASC( ) Function - Returns the ANSI value for the leftmost character in a character expression.
2. MID() Function - The Mid method extracts a substring of length nCount characters from a CHString string, starting at position nFirst (zero-based). The method returns a copy of the extracted substring.
I would really appreciate your help. Thanx!ah yeah! sorry typo error. see, I am converting a VB method that encrypts password:
Function EncryptText(ByVal stDecryptedText As String)
Dim stText As String, lngCounter As Long
Dim iTemp As Integer, lngNumber As Long
lngCounter = 1
lngNumber = 8
Do Until lngCounter = Len(stDecryptedText) + 1
iTemp = Asc(Mid(stDecryptedText, lngCounter, 1))
If lngCounter Mod 2 = 0 Then
iTemp = iTemp - lngNumber
Else
iTemp = iTemp + lngNumber
End If
iTemp = iTemp Xor (10 - lngNumber)
stText = stText & Chr$(iTemp)
lngCounter = lngCounter + 1
Loop
EncryptText = stText
End Function
I converted this function into this:
public static String encryptPass(String password) {
String encpwd = "";
int iTemp = 0;
final int lngNumber = 8;
String stText = "";
for ( int i = 0; i < password.length() ; i++ ) {
iTemp = Character.getNumericValue(password.charAt(i));
if ( i % 2 == 0 ) {
iTemp = iTemp - lngNumber;
} else {
iTemp = iTemp + lngNumber;
iTemp = iTemp ^ (10 - lngNumber);
char c = Character.forDigit(iTemp,Character.MAX_RADIX);
encpwd = encpwd + String.valueOf(c);
return encpwd;
But I'm having trouble with the encryption because it returns a different set of characters. Did I convert it right? thanx.
Maybe you are looking for
-
In Mail, I can not open a viewer window
I just had my hard drive replaced on my 27 inch imac. It came back with a new operating system (OSX10.7.5) Along with that it had several software updates. One of which was Mail. It is now at version 5.3. When I went to open it, it asked to trans
-
I have organised pictures taken in different times into a folder on my phone, but I don't know how to transfer that folder exactly as it is into my computer. When I copy my photos through "My computer" then click on "iPhone device", I usually get the
-
Restricting the change or display authorisation of quotation
Hi, Once the pricing is done at quotation level. It is sent for review to head of department. He will add some profit margin by adding another header surcharge on it. Once the quotation is saved by the department head, no one else can change or displ
-
Apps connecting to strange servers
Hey guys, I use Little Snitch to monitor my outgoing connections. Recently I have noticed apps attempting to connect to peculiar servers. For example, I downloaded the Carbonite trial. During installation I noticed it wanted to connect to "justjared.
-
Cannot now open the mail application - any clues as to how i can fix this ?
Just downloaded Yosemite and cannot now open the mail application - how can i get this back ? thanks