Problems with the name of files (*. hpprgm) and global ids
|
02-11-2018, 09:18 PM
(This post was last modified: 02-13-2018 12:33 PM by compsystems.)
Post: #1
|
|||
|
|||
Problems with the name of files (*. hpprgm) and global ids
Hello, Sorry for my bad translation
A good practice of computer programming is divide and conquer (Folders, subfunctions, etc), which is disseminated in most programming books. The system of the hp-prime allows to call from directory or folder, a identifier or function and works very well =), except that if the file name (pc-name) is renamed it fails =( Example of the use of the dot operator or double colon, binary files below Step 1: create a file with the following name file: dir_pi_main.hpprgm (main file, library) PHP Code: export pi_k:=π; // declares a visible global variable pi_k=3.14159265359 path dir_pi_main::pi_k step 2: Execute the following instruction. dir_pi_main.main_pi_k() [ENTER] // recall the variable pi_k of dir_pi_main returns {3.14159265359} // ok or [tools] program functions dir_pi_main main_pi_k [ok] dir_pi_main.main_pi_k() [ENTER] {3.14159265359} Step 3: create a file with the following name file: dir_pi_2.hpprgm PHP Code: EXPORT main_pi_k() step 4: Execute the following four instructions. dir_pi_2.main_pi_k() [ENTER] returns {3.14159265359} // ok pi_ext1() [ENTER] returns {4.14159265359} // ok pi_ext2 ()[ENTER] returns {6.14159265359} // ok pi_ext3 ()[ENTER] returns {6.14159265359} // ok Step 5: create a file with the following name file: dir_pi_3.hpprgm PHP Code: export pi_k=pi-1; // declares a visible variable pi_k=3.14159265359-1 path dir_pi_3::pi_k step 6: Execute the following three instructions. dir_pi_3.main_pi_k() [ENTER] returns {2.14159265359, 6.14159265359} // ok pi_ext4 ()[ENTER] returns {1.14159265359, 9.14159265359} // ok pi_ext5() [ENTER] returns {1.14159265359, 9.14159265359} // ok Problem #1: If you rename the main file, many functions would fail, because they do not find the correct path One solution is to store in the header a folder name in each file (internal library name), in this way the name of the file is irrelevant (external library name [pc name]), the real path is defined by the header (internal library name) With the new directive file: dir_pi_main.hpppl PHP Code: #FOLDER dir_pi_main // header for real path PHP Code: #FOLDER dir_pi_2 // header PHP Code: #FOLDER dir_pi_3 // header you can check the problem by downloading the files below twice and sending the second download to the HPCONNECTITYKIT and you will notice that a syntax error is generated because it does not include the path, since a postfix (n) to the file is appended 2: second problem In the memory manager, the variables can be reset to zero, but this alters the constant value defined within the algorithm, which produces unexpected results, for this reason to avoid this problem, a possible solution is to define a global variable as constant CONSTANT EXPORT qpiDIGITS Example for test the second problem, binary files below (QPI_4.4.hpprgm) You can check it yourself, resetting the variables qpiEXPLN, qpiMAXINT, qpiDIGITS of QPI_4.4.hpprgm QPI_(1.41421356237) [enter] returns sqrt(2) [shift]+[tools]: user vars: qpiEXPLN (real), qpiMAXINT (real), qpiDIGITS (real) then reset each QPI_(1.41421356237) [enter] returns 1 (failure) PHP Code: export qpiEXPLN:=100; // max denom for exp(p/q) or ln(p/q) please test the codes and tell me Thanks Jaime |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Problems with the name of files (*. hpprgm) and global ids - compsystems - 02-11-2018 09:18 PM
RE: problems with functions that call identifiers and others functions - Carlos295pz - 02-11-2018, 11:29 PM
RE: Problems with the name of files and global variables - compsystems - 02-12-2018, 12:58 AM
RE: Problems with the name of files (*. hpprgm) and global ids - Han - 02-12-2018, 03:51 PM
RE: Problems with the name of files (*. hpprgm) and global ids - Carlos295pz - 02-12-2018, 06:27 PM
RE: Problems with the name of files (*. hpprgm) and global ids - compsystems - 02-12-2018, 05:45 PM
RE: Problems with the name of files (*. hpprgm) and global ids - Carlos295pz - 02-12-2018, 06:14 PM
RE: Problems with the name of files (*. hpprgm) and global ids - Tim Wessman - 02-12-2018, 06:20 PM
RE: Problems with the name of files (*. hpprgm) and global ids - compsystems - 02-13-2018, 12:59 AM
|
User(s) browsing this thread: 1 Guest(s)