Ecriture scientifique ac AppleScript

  • Créateur du sujet Créateur du sujet Ninety
  • Date de début Date de début

Ninety

Membre actif
7 Mars 2006
103
1
Devant mon Mac
Bonjour,

Comment faire pour que mon resultat ne s'affiche pas en ecriture scientifique avec AppleScript ?
Et aussi comment on peut mettre un separateur de millier.

Merci
 
Ninety a dit:
Bonjour,

Comment faire pour que mon resultat ne s'affiche pas en ecriture scientifique avec AppleScript ?
Et aussi comment on peut mettre un separateur de millier.

Merci
Comme le dit le proverbe hindou : "Donne-moi un exemple de ton code, indique-moi précisément le résultat que tu souhaites et je verrai si je puis t'aider." :D :zen:
 
Desoler d'avoir pris un peu de temps a repondre mais j'etais assez occupe :cool:

Voila donc mon code :

Bloc de code:
set [COLOR="YellowGreen"]x[/COLOR] to (60 * (1.5 ^ ([COLOR="YellowGreen"]nivo[/COLOR] - 1)))
set [COLOR="YellowGreen"]y[/COLOR] to (15 * (1.5 ^ ([COLOR="YellowGreen"]nivo[/COLOR] - 1)))
display dialog "Prodx : " & [COLOR="YellowGreen"]x[/COLOR] & " ; Prody : " & [COLOR="YellowGreen"]y[/COLOR] buttons {"OK"} default button 1

nivo est une variable obtenue grace a Text Input, a prioris c'est une valeur entiere.

Merci :)
 
C'est possible à l'aide de la routine "number_to_text" trouvée chez wirinum.

Ce qui donne avec ton code, j'ai choisi 44 pour la variable nivo:

Bloc de code:
set nivo to 44

set xx to (60 * (1.5 ^ (nivo - 1)))
set yy to (15 * (1.5 ^ (nivo - 1)))

set x to number_to_text(xx)
set y to number_to_text(yy)

display dialog "Prodx : " & x & " ; Prody : " & y buttons {"OK"} default button 1

on number_to_text(this_number)
	set this_number to this_number as text
	if this_number contains "E+" then
		set x to the offset of "." in this_number
		set y to the offset of "+" in this_number
		set z to the offset of "E" in this_number
		set the decimal_adjust to characters (y - (length of this_number)) thru ¬
			-1 of this_number as string as number
		if x is not 0 then
			set the first_part to characters 1 thru (x - 1) of this_number as string
		else
			set the first_part to ""
		end if
		set the second_part to characters (x + 1) thru (z - 1) of this_number as string
		set the converted_number to the first_part
		repeat with i from 1 to the decimal_adjust
			try
				set the converted_number to ¬
					the converted_number & character i of the second_part
			on error
				set the converted_number to the converted_number & "0"
			end try
		end repeat
		return the converted_number
	else
		return this_number
	end if
end number_to_text