# HP Forums

Full Version: Good news :-)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Finally the HP-39gII emulator has officially arrived:

Rev.18360 from 4th Sept.

Franz

Thanks, Franz (and HP!). I love the "large" (landscape) skin! I want a real 39gii calculator looking like that one! HP would sell millions of them!!!

Is there any updated firmware yet for my real (portrait) 39gii?

Nigel (UK)

I forget how to display the rev number on mine ! It was not ON & F4 ?

Does this version correct the CASE bug ?

I agree that the landscape skin is great :)

For those interested, here is my first complex program on this device. "Le compte est bon 'in french... Countdown ...

http://en.wikipedia.org/wiki/Countdown_%28game_show%29

```//================================
// Le compte est bon - HP39gII
//--------------------------------
// Variables globales
LOp:={" plus "," moins "," fois ", " divisé par "};
Sol; Cible; Ecart;MeilleurCoup,Tirage;
// Génére une liste contenant la meilleure solution
AffSol (n1,Op,n2,n3)
BEGIN
Sol:=CONCAT(Sol, ""+MAX(n1,n2)+LOp(Op)+MIN(n1,n2)+"->"+n3);
END;
// Le coeur du programme
LCB(Tab,Nb)
BEGIN
LOCAL  i,j,Op,T1,r:=0;
FOR i FROM 1 TO Nb-1 DO
FOR j FROM i+1 TO Nb DO
FOR Op FROM 1 TO 4 DO
Tab=>T1;
IF Op==1 THEN                                                       // To avoid CASE problem
T1(i)+T1(j)=>T1(i);
ELSE
IF Op==2 THEN
ABS(T1(i)-T1(j))=>T1(i);
ELSE
IF Op==3 THEN
T1(i)*T1(j)=>T1(i);
ELSE
IF (T1(j)<>0) AND (T1(i) MOD T1(j)==0) THEN
T1(i)/T1(j)=>T1(i);
ELSE
IF (T1(i)<>0) AND (T1(j) MOD T1(i)==0) THEN
T1(j)/T1(i)=>T1(i);
ELSE
BREAK;
END;
END;
END;
END;
END;
IF T1(i)==Cible THEN AffSol(Tab(i),Op,Tab(j),T1(i)); r:=1; BREAK(3); END; // RETURN(1) don't work
IF ABS(T1(i)-Cible)<Ecart THEN
MeilleurCoup:=T1(i);
Ecart:=ABS(Cible-MeilleurCoup);
END;
T1(Nb)=>T1(j);
IF LCB(T1,Nb-1) THEN AffSol(Tab(i),Op,Tab(j),T1(i)); r:=1; BREAK(3); END;
END;
END;
END;
RETURN r;
END;

// Le programme principal
EXPORT Compte(t,c)
BEGIN
LOCAL n;
Cible:=c;
Ecart:=999;
MeilleurCoup:=0;
Tirage:=t;
Sol:={};
PRINT ("***** LE COMPTE EST BON *****");
PRINT (Tirage);
PRINT ("Nombre à trouver : " + Cible);
PRINT ("");
IF NOT(LCB(Tirage,6)) THEN
PRINT("Solution la plus proche :" + MeilleurCoup);
Cible:=MeilleurCoup;
Ecart:=999;
LCB(Tirage,6)
END;
REVERSE(Sol)=>Sol;
FOR n FROM 1 TO SIZE(Sol) DO
PRINT("   " + Sol(n));
END;
RETURN Sol;
END;
```

For exemple :

Compte({6,6,25,4,100,9}, 923}  Edited: 22 Sept 2012, 7:26 a.m.

Thank for the news. Who is this man who looks at you during download? I find it disturbing!

Gilles .. you are super cool ... I have been working on the same French game .. trying to write an implementation for Excel VBA.

Thank you sooooooooooooooooooo much for your listing!

Namir

Quote: It's not me - I'm much nicer! :-)

Note that the code would be more lisible with CASE :

```
CASE
IF Op==1 THEN T1(i)+T1(j)=>T1(i);      END;
IF Op==2 THEN ABS(T1(i)-T1(j))=>T1(i); END;
IF Op==3 THEN T1(i)*T1(j)=>T1(i);      END;
IF Op==4 THEN
CASE
IF (T1(j)<>0) AND (T1(i) MOD T1(j)==0) THEN T1(i)/T1(j)=>T1(i); END;
IF (T1(i)<>0) AND (T1(j) MOD T1(i)==0) THEN T1(j)/T1(i)=>T1(i); END;
DEFAULT BREAK;
END;
END;
...
```

But there is a bug with the CASE in my HP39 version. HP knows and is working to solve this in futur update

Note also that in the contrary of what is wrote in user guide on the CD, there is no difference between

T1(j)/T1(i)=>T1(i) // dont' know why, but i hate this syntax lol...

and

T1(i):=T1(j)/T1(i)

as you can aloso see, the user guide is not accurate about use of LOCAL variables. You can assing value in the same line than the LOCAL definiton

The BREAK (level) is interesting (but not documented as far i know; Cyrille explain this here)

When I wrote this first verion there was also some problem with the RETURN function in some cases. I think it's solved in the new ROM but not sure.

The HP39gII langage is very interesting, simple and powerfull.

An interesting improvement could be to allow like in PASCAL to call a function (or a procedure in Pascal) with paramaters 'per variable' and not only 'per value' (sorry for my english). This would allow for exemple to swap 2 variables like this :

EXPORT SWAP( VAR : a , VAR : b)
BEGIN
LOCAL c
c:=a; a:=b; b:=c;
END;

and then use
SWAP(x,y) to swap the content of x <-> y .
It's very interesting in many cases

Tim perhaps ;)
"You had to wait a long time, but it' here ! Enjoy "

Edited: 22 Sept 2012, 9:14 a.m.

Ahhh! I love the show "Des chiffres et des lettres" ever since I spend two weeks in a pupil's exchange in France back in 1980. I wonder why this show is running for so long but never was adapted in Germany or elsewhere as far as I know?!?

Edited: 22 Sept 2012, 10:18 a.m.

I assume this is the man who cannot afford a calculator (TM) - therefor the chalkboard in the background <g>

Gilles,

Does the first two nested loops in LCB() cover all the possible arrangements for the six numbers given? I suspect they don't. My Excel VBA version uses SIX loops to do that ... and also uses IF statements to make sure that the indices are not duplicated. I checked with a DEBUG.PRINT statement to verify that I am trying ALL the combinations of the six numbers.

Namir

Gilles,

I was able to adapt your HP39gII code to Excel VBA. I see now that you perform recursive calls to LCB(). Your solution works very well and does it quickly!

<bows down>

Namir