I am trying to create a menu driven program just like we do in c or java to take input from user and perform some operation based on the selected value using a switch case. This is what i am trying to achieve
DECLARE
choice char(1);
radius number;
area number(5,4);
base number;
height number;
BEGIN
dbms_output.put_line('A. Area of Circle');
dbms_output.put_line('B. Area of Triangle');
dbms_output.put_line('C. Area of Sphere');
choice :=&choice;
case
when choice='A' then
radius:=&radius
area = radius*radius*3.14;
dbms_output.put_line('Area of circle is : ' || area);
when choice = 'B' then
base:=&base;
height:=&height;
area=0.5*base*height;
dbms_output.put_line('Area of Triangle is : ' || area);
else
dbms_output.put_line('Invalid Choice');
end case;
END;
/
But the problem is it doesn't even output the first 3 lines and directly jump to the choice:=&choice statement.Also the case is not working.
Related
I'm trying to do an OUTER-JOIN in progress using this page as inspiration. My code is as follows
OPEN QUERY qMovto
FOR EACH movto-estoq
WHERE movto-estoq.lote BEGINS pc-lote
AND movto-estoq.it-codigo BEGINS pc-it-codigo
AND movto-estoq.dt-trans >= pd-data1
AND movto-estoq.dt-trans <= pd-data2
AND movto-estoq.cod-emitente = pi-cod-emitente,
EACH item OUTER-JOIN
WHERE movto-estoq.it-codigo = item.it-codigo,
EACH item-cli OUTER-JOIN
WHERE item-cli.item-do-cli BEGINS pc-item-cli
AND movto-estoq.cod-emitente = item-cli.cod-emitente
AND movto-estoq.it-codigo = item-cli.it-codigo
AND movto-estoq.un = item-cli.unid-med-cli,
EACH nota-fiscal OUTER-JOIN
WHERE movto-estoq.nro-docto = nota-fiscal.nr-nota-fis
BY movto-estoq.dt-trans DESCENDING BY movto-estoq.hr-trans DESCENDING.
The problem that is happening is when 1 element in null, all the other elements that are in the OUTER-JOIN are appearing as null as well, even though they are not null. Is there a better way to write this code? Should I put 'LEFT' before the OUTER-JOIN? Thanks for your time.
To make your example easier, consider making it work from ABL dojo. The following code:
define temp-table ttone
field ii as int
.
define temp-table tttwo
field ii as int
field cc as char
.
create ttone. ttone.ii = 1.
create ttone. ttone.ii = 2.
create tttwo. tttwo.ii = 2. tttwo.cc = "inner".
create tttwo. tttwo.ii = 3. tttwo.cc = "orphan".
define query q for ttone, tttwo.
open query q
for each ttone,
each tttwo outer-join where tttwo.ii = ttone.ii.
get first q.
do while available ttone:
message ttone.ii tttwo.cc.
get next q.
end.
Can be run from https://abldojo.services.progress.com/?shareId=600f40919585066c219797ed
As you can see, this results in :
1 ?
2 inner
The join which is not available is shown as unknown. The value of the outer part of the join is shown.
Since you do not show how you are getting an unknown value for everything, maybe you are concatenating the unknown values?
I know BASIC is a deprecated language but it's fun to play around with. I'm using FreeBASIC on Windows and I'm trying to re-compile an old program that I originally wrote for the Apple ][.
One instruction that no longer works is HOME, which coincidentally HOMEs the cursor. I found this about getting/setting the cursor position in VB.NET, but as I'm using BASIC I assume it will not work.
Therefore, my question is... how can I get/set the cursor position in BASIC?
You can set the cursor position using LOCATE:
CLS
LOCATE 3, 30
PRINT "Hello World"
GETKEY
END
LOCATE can be used as a function as well to detect the current cursor position. But there are also dedicated functions for that, CSRLIN and POS.
Considering that your program is working in a textual environment 25 Lines x 80 Columns (CGA Text Mode 640x200)
Syntax for FreeBASIC
dim as integer column = 0, row = 0 'Set the variable for store the position
dim as string char = "" ' Set a variable for store the pressed key
cls ' Clear the screen
row = csrlin ' read the actual cursor row and store inside the var row
column = pos ' read the actual cursor column and store inside the var column
do until ( char = chr(27) ) ' make a loop until you press ESC key
char = inkey ' store the pressed key in char variable
if not(char = "") Then ' When you press a key and char store the pressed key then start this routine
if not(char = chr(27)) then ' if pressed a key and not are the ESC or Enter or backspace key
if char = chr(13) then ' when press enter
row = row + 1 ' add a new line if enter are pressed
if row > 23 then row = 23 ' put the stop at row 23
column = 0 ' Put the column at beginning
end if
if char = chr(8) then ' when press backspace
locate row, column
print " "
column = column - 2 ' remove a value from column
if column < 0 then column = 0 ' column cant be lower than 0
end if
if column > 79 then column = 79 ' stop the cursor at 79 column
locate row, column ' move the cursor where
print char ' print the key pressed
column = column + 1 ' add a value to the initial value
end if
locate 24,60 : Print "Row:(" & str(Row) & ") Column:(" & Str(Column) & ")" ' this show where the next cha appair
End if
loop
Forgive me if I correct your opinion, but BASIC has evolved like other Programming Languages, VB.NET and FreeBASIC, where you can develop objects, libraries and take advantage of libraries written in other languages like C and C ++, Currently the same FreeBASIC is a Port of C and as like him has the same potential, in fact it is possible to develop applications for graphical and textual environment on Linux and Windows, you can implement libraries to use databases like MySQL and Oracle, also the same FreeBASIC manages multiple threads to run multiple processes simultaneously .
GetMouseX does not work when using a graph window.
uses wincert,graph,winmouse;
var x,y:integer;
Begin
x:=GetMouseX;
End.
This gives me Error:Identifier not found "GetMouseX".
Trying this with unit 'mouse' works in the console window, but not in the graphics window.
Can anyone please help?
Yes, winmouse is not a version/subset of mouse like wincrt is a subset of crt for windows "graph" use..
It is just an unit to let mouse work with graph. Look at the unit to see what functions are available (lpressed,rpressed,getlastbuttonpress etc)
After a long search I managed to find a list of functions for winmouse. The page was in... Polish or something, but the example code worked like a charm.
uses graph, wincrt, winmouse;
var gd,gm: integer;
ch:char;
i:integer;
mposx, mposy, state: longint;
begin
gd := d4bit;
gm := m640x480;
initgraph(gd,gm,'');
initmouse;
randomize;
for i:=1 to 10 do
circle(random(640),random(480),150);
repeat
if keypressed then ch:= readkey;
if lpressed then
begin
repeat until not lpressed;
getmousestate(mposx,mposy,state);
if getpixel(mposx,mposy)<15 then
begin
setfillstyle(solidfill,random(14)+1);
floodfill(mposx,mposy,15);
end;
end;
until ch = #27;
closegraph;
end.
Thanks for the help.
I need to load a single bitimage to a Pascal program, is there a way to do it or I must draw pixel by pixel?
As far as I remember, Turbo pascal had functions
GetImage(X1, Y1, X2, Y2: integer; var BitMap)
PutImage(X, Y: integer; var BitMap; BitBlt: word);
BitMap is just a chunk of memory with the bitmap. This way you can get image from screen to memory and vice versa. I think there is no direct function to get image from file to screen. But if you have image in right format on the disc, you can load it to memory and then use PutImage.
By using graph unit you can load BGI graphics in turbo pascal.
Refer this for more info...
http://pascal-programming.info/lesson8.php
Here is a sample code from the above link...
Program Lesson8_Program1;
Uses Crt,Graph;
Var GraphicsDriver, GraphicsMode,
ErrCode : Integer;
{two var's are needed for initialisation}
Begin
Writeln('Initialising Graphics, please wait...');
GraphicsDriver := Detect;
InitGraph(GraphicsDriver, GraphicsMode,'');
{IMPORTANT, read the following or
otherwise graphics will not work!! ;)}
(*between the inverted commas,
type in the path of the graphics BGI file
(usually 'C:\TP\BGI'),
OR
change the dir in the file menu (PRESS Alt+F)
and roll down your mouse pointer to the 'change dir'
menu; then either type the path to the BGI file,
or go to C: -> TP -> BGI*)
ErrCode := GraphResult;
If GraphResult <> grOK then { <> means 'not equal to' }
Begin
ClrScr;
Writeln('Graphics error occured: ',
GraphErrorMsg(ErrCode));
Writeln('If a file not found error is displayed above');
Writeln('then, change the dir from the current');
Writeln('location to C:\ -> TP -> BGI, '+
+'from the file menu!');
Readln;
Halt(1);
End Else
Begin
Randomize;
SetColor(Random(15) + 1); {Set text colour}
{Output text at 20 pixels from the top of the screen,
and 20 other from the left side of the screen.}
OutTextXY(20,20,'Welcome to the new generation
of Pascal Programming:');
OutTextXY(20,30,'Pascal Graphics!!');
OutTextXY(25,70,'You will learn more
graphics procedures and');
OutTextXY(25,80,'functions, later in this lesson :-)');
Readln;
End;
CloseGraph;
End.
Refer this for more info...
http://pascal-programming.info/lesson8.php
Is there any tool I can use to perform pseudolocalization on an ASP.NET MVC app (using the Razor view engine) in order to help localizability testing?
i wrote a small utility app that lets me convert text into "pseudo".
It's based on a simple function which looks at each character in the string. If the character IsAlpha then i add an accent to it.
i add an accent by appending the character with a random diacritic mark between U+0300 and U+036F (the diacritical marks range).
So now i just localize my application/web-site like i were one of the dutch speaking localizers.
ỉ w͝rͨo͡t̮e̤ a͈͟ s̏m͈a͞l̪lͅ u͇t̽i̡l̔i͜țy̭ a͟p̉p͕ t̼h̥aͤt̖͊ l͊e̗t̘s̈́
m̶eͭ c͟o̙n̚v̈e̲r̓t̝ t͌e̽x̳t͈ i̍n̔t̖o̺ "p̪̜s̔e̊u̟d̮o̱".
I͔t͒'sͪ b̞aͧs̜e̋dͫ o̸͚n͙ a̼ s̼i̥m̢ͫpͫl͗e̺ f̙uͪn͎̉c͙t͒ḯo̾n̑ w̰h̙i̷c͟ḣ̌
l̼óoͦk͔s͑ a̬t̆ e̓a̔c̈hͭ c̚h̻a̿r̴aͭc̤t̙eͦŗ͉ i̞n̴ t̀h̸e̮ͫ s̖t͘r͕i͇n͒g̴͐.
I̳fͣ t̰ĥe̿ c͋h͡a͖r̸a̸c̟t̼e̞rͪ Ìs̀A̒l͒p̷h̗a̲ ţh̽e͚nͥ i̡ a̰d͙d̬
a̅n̊ a̐c̒c̒e̤͞n̜t̽ t̆o͑ i̴tͪ.
i̋ a̸d̋d́ a̰n̏ a͛c͏c̣͗e̾n͡t̎ b̷̞ẏ a̐p͞p̧͔eͩn͊ḍ͋ín̓g͚ t̬h͚ẹ
ćh̞a͗ŗa͖c͐t̊e̷rͅ w͙iͩt̮hͮ a͡ r͙a͋nͅd̃o͞m̚ dͬi̠a͚c̸r̾iͩt͖i͋c̭ m̓ḁr̵k̡
b̞ë́t̼w̓e̬ë́n̨ U̵+0300 a̢n͙d͜ U͕+036F͓ (t̯͉hͪ͟eͮ
d͓i͉aͣc͕̬r͜i͒t́i͓c̯a͚l̼ m̓a̅r̝̜k͎s̯ r͋ăn̪̒g̟e̱̮).
There's also an option to add padding to text, so allow for other languages not using the same amount of space as english
Today -> [T̀oͨd̼a͈̹y̭ !!]
Control Panel -> [C̊ȍńt̪r͗o͂l͇ P̈ȁñeͮl͢ !!!!!]
Oxydative Decarboxilation -> [Ŏx͞y̠dͥa͂t̿i̚v͙eͪ D̼e̖c̿aͤr͖b̐o̼x̹i͂l͖a̠t̮i̓o̧n̰ !!!!!!!!!]
And my PsuedoLocalizeText function:
function TForm1.PsuedoLocalizeText(s: WideString; AddPadding: Boolean): WideString;
var
i: Integer;
sb: TWideStringBuilder;
x: Integer;
tiny: WideString;
const
n: WideString = ''; //n=nothing
begin
//Code is public domain. No attribution required.
sb := TWideStringBuilder.Create;
try
for i := 1 to Length(s) do
begin
//http://www.fileformat.info/info/unicode/block/combining_diacritical_marks/list.htm
//U+0300 .. U+36F are combining diacritic marks
x := $300+Random($36f-$300);
if Windows.IsCharAlphaW(s[i]) then
begin
tiny := n+ s[i] + WideChar(x);
if Random(10) < 1 then
tiny := n+tiny+WideChar($300+Random($36f-$300));
sb.Append(tiny);
end
else
sb.Append(s[i]);
end;
Result := sb.ToString;
finally
sb.Free;
end;
if AddPadding then
begin
Result := '['+Result+' ';
for i := 1 to Ceil(Length(s) / 3) do
begin
Result := n+Result+'!';
end;
Result := Result+']';
end;
end;
Update My psuedolocalizer:
My next task is to have it work on *.resx, but exclude *.xx-yy.resx, so it can work on WinForms applications as well.
And of course fill in Size, Attributes, get the right icon for Folders.
Then maybe have it highlight the fr-FR or qps-ploc part of filenames.
There is a "pseudoizer" tool in the downloads for this article: http://msdn.microsoft.com/en-us/magazine/cc163991.aspx
It includes both source (winforms) and binary if you're lazy
After not finding anything quick, free and easy, I built Pseudolocalize.com! Just copy/paste/click and you've got the pseudolocalized version of your strings!