Global Variables?
|
04-03-2017, 12:40 AM
Post: #1
|
|||
|
|||
Global Variables?
Is there a way to make global variables using uppercase letters?
I'd like to use N:=20; outside a begin-end block. I'd also like to be able to use R:=makelist(0,100); I get syntax errors for both. N1:=20; and r:=makelist(0,100); both work. however. Tom L Tom L Cui bono? |
|||
04-03-2017, 02:10 AM
(This post was last modified: 04-03-2017 02:13 AM by Joe Horn.)
Post: #2
|
|||
|
|||
RE: Global Variables?
(04-03-2017 12:40 AM)toml_12953 Wrote: Is there a way to make global variables using uppercase letters? The permanently-existing, built-in variables are "reserved" by the system and always contain specific object types. For example, A-Z always exist as global variables, and always contain a real number, and cannot be purged. That's why you can't assign a list to 'R'. The reason 'N1' and 'r' do work in your example above is because they are not reserved variables, so they can contain any object type, or nothing at all (after being purged). A hopefully-complete list of Prime's reserved variables can be found HERE. <0|ɸ|0> -Joe- |
|||
04-03-2017, 02:59 AM
Post: #3
|
|||
|
|||
RE: Global Variables?
(04-03-2017 02:10 AM)Joe Horn Wrote:(04-03-2017 12:40 AM)toml_12953 Wrote: Is there a way to make global variables using uppercase letters? Thanks, Joe. I knew about that but also know you can create local variables as any type you want. I was hoping there was some way to create a variable local to the program but global to all the subprograms in the program. Tom L Tom L Cui bono? |
|||
04-03-2017, 03:02 AM
Post: #4
|
|||
|
|||
RE: Global Variables?
(04-03-2017 02:59 AM)toml_12953 Wrote: Thanks, Joe. I knew about that but also know you can create local variables as any type you want. I was hoping there was some way to create a variable local to the program but global to all the subprograms in the program. Just declare them at the top of your source file. Code:
Graph 3D | QPI | SolveSys |
|||
04-03-2017, 10:11 AM
(This post was last modified: 04-03-2017 10:12 AM by toml_12953.)
Post: #5
|
|||
|
|||
RE: Global Variables?
(04-03-2017 03:02 AM)Han Wrote:(04-03-2017 02:59 AM)toml_12953 Wrote: Thanks, Joe. I knew about that but also know you can create local variables as any type you want. I was hoping there was some way to create a variable local to the program but global to all the subprograms in the program. The point of my post was that that doesn't work with uppercase variables. Try this: Code: N:=100; Tom L Cui bono? |
|||
04-03-2017, 10:25 AM
Post: #6
|
|||
|
|||
RE: Global Variables?
(Second line in your code block):
R is a reserved variable for reals only. |
|||
04-03-2017, 01:18 PM
(This post was last modified: 04-03-2017 03:07 PM by compsystems.)
Post: #7
|
|||
|
|||
RE: Global Variables?
Even with correct data generates an error, I think because a reserved variable is global for all programs and not a specific one.
The compiler should say the cause of the problem, instead of just SYNTAX ERROR PHP Code: X:=100; |
|||
04-03-2017, 04:39 PM
Post: #8
|
|||
|
|||
RE: Global Variables?
(04-03-2017 10:25 AM)DrD Wrote: (Second line in your code block): Yes, I know that but my question was - since R:=MAKEMAT(0,100); works for local variables, is there a way to make it local to the current program file but global to all the subprograms in that file. The answer as it turns out is "No" Tom L Tom L Cui bono? |
|||
08-15-2021, 12:27 AM
(This post was last modified: 08-15-2021 12:35 AM by jte.)
Post: #9
|
|||
|
|||
RE: Global Variables?
(04-03-2017 02:10 AM)Joe Horn Wrote: ⋮ A nice & useful list! I did notice that descriptions are missing for a bunch of the Graph 3D app variables. Descriptions for those whose GUI resides on page 3 of Graph 3D's Plot Setup view (BoxSides, BoxFrame, BoxAxes, BoxLines, BoxDots, and BoxScale) can be brought up by pressing Help after selecting one of them (BoxSides, say) from the Vars / App / Graph 3D / Plot choices. The "Box..." settings have to do with a virtual "box" that surrounds the plotted functions. Some of these may be understood quickly by interacting with a Graph 3D plot view with only one enabled at a time (going to page 3 of Graph 3D's Plot setup view, setting all but one to "None" / unchecked). Similarly for those whose GUI resides on page 2 of Graph 3D's Plot Setup view (GridX, GridY, Surface, and KeyAxes). The KeyAxes is the little RGB XYZ axes display resident (when enabled) in the top left of Graph3D's Plot view. ... and, again, similarly for those whose GUI resides on page 4 of Graph 3D's Plot Setup view (BoxScale, PoseXaxis, PoseYaxis, PoseZaxis, and PoseTurn). The Pose... variables have to do with the orientation of the plot (transformation from the abstract XYZ space of the function surface plot to the XY coordinates of the screen). The user-facing description is intended to be a rotation around a vector (a turn of PoseTurn around the vector [PoseXaxis, PoseYaxis, PoseZaxis] if the XY plane of the abstract XYZ coordinates is aligned with the XY screen plane of the calculator). Zmin, Zmax, and Ztick are direct analogues of Xmin, Xmax, and Xtick. (Or Ymin, Ymax, and Ytick.) Zmin and Zmax control the volume being plotted (which interval of Z the plot is for) while Ztick controls plot decorations (dots and lines). Zzoom is similar to Xzoom and Yzoom: Zzoom controls the amount of zooming done along the Z dimension when a zoom is done in a Graph 3D Plot view. (I started typing in descriptions of them just now, before realizing that there should be some online Help for them.) FZ0-FZ9 are direct analogues of F0-F9 (from Function): these are the symbolic definitions of the functions considered for plotting. (Plotted if checked.) (Z0-Z9 are not used in Graph 3D as they were already reserved for complex variables.) I also noticed PPL variables are missing for some of the controls present in Graph 3D's Plot Setup view and that some of the Help has formatting issues. Some of the variables in Graph 3D could be better understood / communicated with a diagram or two. |
|||
08-15-2021, 12:49 AM
Post: #10
|
|||
|
|||
RE: Global Variables?
(08-15-2021 12:27 AM)jte Wrote:(04-03-2017 02:10 AM)Joe Horn Wrote: A hopefully-complete list of Prime's reserved variables can be found HERE.A nice & useful list! Yikes! I created that list out of necessity, before the reserved variables were included in the built-in Help system. My list is now very out of date, and has been obsoleted by the Help system. I'll delete it as soon as I get access to my FTP server. Thanks for bringing it to my attention. Time flies when you're having fun! <0|ɸ|0> -Joe- |
|||
08-15-2021, 01:22 AM
Post: #11
|
|||
|
|||
RE: Global Variables?
(08-15-2021 12:49 AM)Joe Horn Wrote:(08-15-2021 12:27 AM)jte Wrote: A nice & useful list! Oh! I like that it is a big list all in one place. I wasn't suggesting deletion or anything like that. By "obsoleted", I'm guessing you mean the Catalog in Vars — that it is a comprehensive list and that descriptions of the variables included there can be obtained via the Help key. (Am I right?) Perhaps a possible improvement to the help system is to have the particular variable automatically highlighted in the brought-up help (after pressing Help while in Catalog or in an editor) and have the brought-up help automatically scrolled to show the highlighted word. Some syntax colouring (to, e.g., call out names reserved by the system) when editing a PPL program might be useful for beginners. |
|||
08-15-2021, 03:57 AM
Post: #12
|
|||
|
|||
RE: Global Variables?
(08-15-2021 01:22 AM)jte Wrote: By "obsoleted", I'm guessing you mean the Catalog in Vars — that it is a comprehensive list and that descriptions of the variables included there can be obtained via the Help key. (Am I right?) Exactly right. Kudos to HP for adding that feature. <0|ɸ|0> -Joe- |
|||
08-18-2021, 04:37 AM
(This post was last modified: 08-18-2021 04:41 AM by cahlucas.)
Post: #13
|
|||
|
|||
RE: Global Variables?
(04-03-2017 04:39 PM)toml_12953 Wrote:(04-03-2017 10:25 AM)DrD Wrote: (Second line in your code block): Dear Tom, Try this code (it works on my G2): Code:
I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
08-18-2021, 09:55 AM
Post: #14
|
|||
|
|||
RE: Global Variables?
(08-18-2021 04:37 AM)cahlucas Wrote:(04-03-2017 04:39 PM)toml_12953 Wrote: Yes, I know that but my question was - since R:=MAKEMAT(0,100); works for local variables, is there a way to make it local to the current program file but global to all the subprograms in that file. The answer as it turns out is "No" Strange... I get a SYNTAX ERROR at the first LOCAL. Tom L Cui bono? |
|||
08-19-2021, 04:50 AM
(This post was last modified: 08-19-2021 04:51 AM by cahlucas.)
Post: #15
|
|||
|
|||
RE: Global Variables?
(08-18-2021 09:55 AM)toml_12953 Wrote:(08-18-2021 04:37 AM)cahlucas Wrote: Dear Tom, Dear Tom, That's strange... Did you enter the program exactly as I did? The LOCAL statement must be within the BEGIN and END; words, and terminated with a ;. What can also matter is whether you use a G1 or a G2. Another hint: put the following on the first line of your program: # pragma mode(separator(.,;) integer(h32)) (first a period, then a comma, and finally a semicolon). I hope it works now. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
08-19-2021, 08:57 AM
(This post was last modified: 08-19-2021 09:08 AM by toml_12953.)
Post: #16
|
|||
|
|||
RE: Global Variables?
(08-19-2021 04:50 AM)cahlucas Wrote:(08-18-2021 09:55 AM)toml_12953 Wrote: Strange... I get a SYNTAX ERROR at the first LOCAL. Yes, I entered it exactly by copying and pasting the code onto my G2. I'll try the pragma ... OK, I just tried the pragma and still get a syntax error at the same place. Here's what I have: Code: #pragma mode(separator(.,;) integer(h32)) Tom L Cui bono? |
|||
08-19-2021, 03:38 PM
Post: #17
|
|||
|
|||
RE: Global Variables?
(08-19-2021 08:57 AM)toml_12953 Wrote:There is sometimes an issue with the spaces in the pasted code. Remove and replace(08-19-2021 04:50 AM)cahlucas Wrote: Dear Tom, the spaces on the calculator both before and after LOCAL. Hopefully that fixes it but other errors might then be apparent further down. |
|||
08-20-2021, 04:04 PM
(This post was last modified: 08-20-2021 04:05 PM by cahlucas.)
Post: #18
|
|||
|
|||
RE: Global Variables?
(08-19-2021 08:57 AM)toml_12953 Wrote: There must also be a space between # and pragma. In my reply from Thursday, I stated it correctly. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
08-20-2021, 06:26 PM
Post: #19
|
|||
|
|||
RE: Global Variables?
(08-20-2021 04:04 PM)cahlucas Wrote:(08-19-2021 08:57 AM)toml_12953 Wrote: When I put a space between # and pragma, I get a syntax error at the beginning of the word mode. Tom L Cui bono? |
|||
01-20-2023, 02:46 AM
Post: #20
|
|||
|
|||
RE: Global Variables?
(08-19-2021 03:38 PM)Stevetuc Wrote: ⋮ As I’ve just mentioned (https://www.hpmuseum.org/forum/thread-99...#pid168514), a small change has been made to the HP Prime language parser that should help with this (I filed a ticket on this issue on the bug tracker I’ve set up; that ticket has been addressed) — for the parser to treat non-breaking space (U+00A0) as space itself (U+0020) is. This should make code sharing a little more convenient / less likely to introduce confusion. (If anyone reading this would like an account on the bug tracker I’ve set up to help organize matters, just let me know by PM.) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 10 Guest(s)