Can someone show a known good working function in Xojo 2014? - macos

So.. I just downloaded Xojo 2014 for OS X, and up to this point have found it a pretty simple and effective development environment.
However, I've been trying to make a function or sub routine for 45 minutes. Every time I try following tutorials or the Xojo documentation I get the following error:
I've followed (even though I could be missing something) the directions here: http://docs.xojo.com/index.php/Function
Even though there is no full example in the documentation (bad development environment).
Also, in the screen shot is showing a sample function I copied and pasted off Xojo forums and is supposed to work. I'm not a programming newb per say, but more an Xojo newb. I've also had experiences with silly bugs in RealStudio in the past.
Can someone maybe point out what I could be missing?

You cannot use the Function, Sub, End Function, or End Sub lines in the method editor. Doing so will cause a syntax error because method declarations are automatically added by the IDE based on the values you enter into the method editor's name, parameters, and return type fields.
e.g.

as said,
Function, Sub, End Function, or End Sub is done for you,
you can do 'exit sub' if nothing need to be returned, else just return a proper value
like some events need a true or false, so if you need the exit the function, just return false

You cannot add inline functions within your Xojo code. You add methods to your project items these ways:
Insert->Method
"+" button on editor toolbar, then Method
Insert button on main toolbar, then Method
Option-Command-M (on OS X)

Related

How to display a value to the homescreen during a ti-89 titanium program

In relationship to this thread, this is also what i am kind of trying to do but i have had a bit more leeway in this.
My problem is i am currently working on a defining program (for my ti-89 titanium) to write out the definitions of variables. However, considering i had indefinite amounts of variables to add, i thought using the define function over and over again would waste memory and processing power. So my thinking was Save the variable to another variable to be defined in a later portion of the program.
prompt x
lbl x_d_r
x_d_r->q:Goto def
lbl def
define expr(q)[1]=x
where x_d_r has no assigned value. So the program was supposed to use the defined string as a list value to be x. However the obvious error came about.
So i played around on the home screen and program screen for a bit and came across entry(1) and ans(1). See back on the ti-83 (or 84) i could basically go (If i remember correctly)
disp q*1
x->ans(1)
However ans(1) on a ti-89 titanium is based upon the last answer submitted to the homescreen. Even then, ans(1) or entry(1) gets replaced in the program by just that. Lucky me, i found a way to avoid this.
Prgm
expr(char(120)&char(22)&char(97)&char(110)&char(115)&char(40)&char(49)&char(41))
EndPrgm
For those that do not know, this is simply expressing x->ans(1) which is a way for the code to transmit ans(1) within a program without removing the code to say so.
But it still does not work as a value needs to be sent to the home screen in order for it to record properly. This is one of those advantages that the ti-84 or ti-83 i wish it still had on the titanium. So i have spent some time searching for ways how i can display values of q to the home screen from within a program.
So far i learned that functions when used straight from the home screen return the value of q to the same place. However i have no way of implementing this in an actual program as the function does not wish to transmit the value to the home screen, and its rather useless within the program.
Secondly i have found this website which details methods of such ways to return values to the homescreen. While method 1 seems to hold promise, i do not seem to have any way of accessing that folder/program. Most likely because it is one that he made and has not shared its location on the pdf. I do like the expr("q"&":stop"), but q is not evaluated out so maybe i would have to rework it somehow.
While this was happening, i thought some other ideas could be using the paste key within a program but i have no idea how to implement stuff found from getkey let alone how the second and grab buttons factor in.
Or i could somehow have the ans(1) look to someplace else other than the home screen. Preferably to the i/0 screen but maybe to some other list or data matrix.
Anybody have any ideas on how to relay a value to the homescreen be it through function, pasting or something, and have the program i defined earlier define it as a value?
UPDATE+1
Ok i am beginning to question if maybe i am making it more complex than it needs to be...
After all, i am only going for just x->x_d_r[1], which is already defined elsewhere. So does it beat x->q:Goto def
Lbl def
Define expr(q)=x
(Or something like that which calls to a history recording program to define values?)
in terms of processing speed and memory count?
Got it. See here for what i was really trying to do.
So as an explanation of what the main problem was again, i wanted to be able to post a string value of q to be defined by another value of x.
The expr( function is quite a powerful tool on the ti-89 and like the person in that other forum, underestimated it. See what the person was trying to do was
InputStr "Function:",f(x)
expr(f)→f(x)
And was later answered by reworking it as
InputStr "function", n
expr(n & "->f(x)")
The expression tool just simply expresses what is in the parentheses. So during break periods in school today, i reworked in my head thinking "What if i tried rewriting the parenthesis out so it reads Expr("x->"&String(q))?
Lo-and-behold it works. Tested it with the fuller version of define to get
td()
Prgm
Prompt X
x_d_r->q
expr("x->"&string(q)&"[1]")
Disp x_d_r[1]
Delvar x_d_r
EndPrgm
Tried, tested and true. Works all the way. See what i think is happening is that anything that is not within the quotes is evaluated immediately in an expression while the the quoted objects are simply expressed and added later in response to the "&" key. Furthermore it makes sense if i was to describe it more with english; "Express x to be stored into the string of q's respective table".
While for variables sake i would have to look into ways to make x_d_r local only to the program without compensating the fact that the x_d_r portion is not considered a store value when executing x_d_r->q. But knowing what i know now i could probably do
expr("q"+"x_d_r"&->a)
expr("x->"&string(a)-"q"&"[1]")
In order to bypass that problem.

Syntax error when using Me in VB

Here's an interesting thing, I have used Visual Studio 2010 previously to make basic VB programs, and never had an issue with anything. Now I am just perplexed as to why this is happening.
I haven't even gotten very far into the coding phase of the first form, and already I am getting yelled at for a syntax error when I use "Me", whether it is Me.Close(), or whatever. Instead of posting the code as text here, it would be best to just show the syntax highlighting.
http://kelina-enterprises.com/img/vb-syntax-error-stackoverflow.png
::EDIT:: This image was taken down, it is not a real error.
Here's the funny thing, when I test the program, it runs just fine if I run the last successful build, which executes those "errored" lines.
Is this something I should even concern myself with, or should I just ignore these apparently false syntax errors?
Do keep in mind that if this is something simple that I have just neglected to take care of for some reason (nothing comes to mind), it has been about 3 years since I last used VB, and not even for a year at that.
You cannot write VB statements inside a Class, such as, Me.Close() or MessageBox.Show("??"). For example,
Class Test
MessageBox.Show("test")
End Class
is obviously syntax error
Inside a Class, you can write only declarations or methods.
In your case, you can place the codes in the Load event handler like this ...
Private Sub LoginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Fullscreen, over everything, maximized
Me.Width = My.Computer.Screen.WorkingArea.Width
Me.Height = Screen.PrimaryScreen.Bounds.Height
Me.CenterToScreen()
Me.TopMost = True
Me.WindowState = FormWindowState.Maximized
End Sub
You don't need to type-in the Private Sub ... End Sub. Go to form design, double click the form and the Load event should be appeared.
It looks like you mean to put that code within the load event of the form, you can't have code that's not inside some sort of routine.
If you double-click on the form in design mode, the load event should be automatically created for you and you can then move the code into it.
There are also other events of the form that you may want to use, e.g. Shown event, these can be created by clicking on the appropriate selection in the drop-down box next to the one that has LoginForm selected.

Matlab GUI changes 2009a->2011b?

I have a skeleton GUI application which puts up a simple set of menus whose entries share a common callback function whose only effect is to set the value of a global variable, MenuItem, which is different for each entry. Different functions are then called for each value of MenuItem inside a Switch-Case expression, the Switch-Case is held inside a While loop whose exit condition is for MenuItem to attain a certain value. In the tail of the While loop is a uiwait call, after the Switch-Case.
This worked fine under Matlab 2009a but since I upgraded to Matlab 2011b it is broken.
Under Matlab 2011b the value of MenuItem is changed in the callback but this changed value does not seem to propagate into the Switch-Case.
Any ideas of changes between 2009a and 2011b which might have caused this, and workarounds for them? I tried reading the release notes but couldn't spot anything which appeared relevant.
(I appreciate this is a slightly unorthodox way of structuring a GUI, it is born out of a background in commandline programming)
I don't think the GUI API has changed in MATLAB between 2009a and 2011b. If the MenuItem changes do not propagate into the switch cases, then you should check that the case statements that you compare against are still valid. You should at least post your code around the switch statement in order to make a more reasonable diagnosis.

Code completion for multi-parameter method names in Xcode 4

In Xcode4, I'm finding that I can't get code completion to readily narrow for multi-parameter method names where the first part is common. For example, consider the following methods from UITableViewDelegate:
- tableView:viewForHeaderInSection:
- tableView:heightForHeaderInSection:
- tableView:accessoryTypeForRowWithIndexPath:
...
The list goes on; there are quite a few methods that start tableView. If I type "tableView", the list is long and not quickly navigated. If I type "tableView:", code completion is exited as soon as I type the colon (:). If I type a run-on such as "tableViewview", completion also exits, presumably as it no longer literally matches the first method name part.
Is there some way to complete via the keyboard on such a list without resorting to either mousing around or clattering out a random number of arrow key hits to navigate the long list? I'm having a hard time believing that code completion for multi-parameter Objective-C methods is so limited, but neither experimentation nor documentation have proved illuminating thus far.
Update for clarification:
Above I'm referring to completion of a method declaration (e.g. in a .m file), not of a method call. For method calls, Xcode 4.x does completion for each method parameter part independently; this works great. The problem above only applys to declarations, generally when starting to write a new method implementation in a .m file.
It does seems that the behavior you expect is (unfortunately) not implemented in Xcode. However, I've found a partial solution: code completion works when you specify the complete first part of the multi-parameter method, i.e. if you type this (with space at the end)
- tableView:(UITableView *)tableView
and press ESCAPE key then the code completion dialog will appear and you will be able to keep typing the rest of the method name.
You are probably wondering:
"Oh boy, do I really have to type in this long preamble just to get
my code completion?"
Code snippets to the rescue! You just have to type the preamble once and convert it into snippet. I found it's best to configure it the following way, don't forget to add space at the end of code part, it will make things easier.
How should you use the thing you've just created? In your .m file start typing tabl and Xcode will let you autocomplete the snippet for you. Once the preamble is placed press ESC to reveal the auto-completion list.
This solution is not very robust, since you have to create a snippet for every multi-part method you want to use, but it does save some time and there aren't that many multi-part method names that share the same prefix.
I'm annoyed by this problem for quite a long time. Now I can verify that there is no way to do even in the newest Xcode 5, I submitted a bug report:
Multi-parameter method declaration completion in Xcode
Please dup it if you also want it.
Oh sorry, it does not work that way I mentioned with protocol stubs like you wanted in your update.
I use Accessorizer for that, an app in the mac app store to fully implement the declaration of your delegate/protocol methods you want to implement. Hope that help a little bit.
Old post:
I use Tab ⇥ for this.
Example I often have:
You want one of many init methods in the code completion.
Then you don't want to scroll down or use to many keystrokes to get to the right method.
Hit i > hit Tab ⇥ > init is completed.
Hit Escape ⎋ and then w and then again Tab ⇥ for all these initWith methods.
You can even use Tab ⇥ / Escape ⎋ after the first parameter, when there is more than the method with only one parameter.
In your case hit t > Tab ⇥ > Escape ⎋ > a and Return ↩, there you got your third method.
You can also jump to the previous code completion argument with Shift ⇧ + Tab ⇥.

VB6 app controlling Word behaves differently during debug than when compiled

I have a vb6 app that uses Word interop to create a few reports. In the introduction of these reports, there are some instructions in 4 textboxes around an image.
Recently and suddenly the top two textboxes started appearing on the next page, and I can't figure out why. When I step through the code and watch the word document getting built, everything positions itself correctly, however, if I compile the application, the error reappears.
Any suggestions?
Use late-bound calls to Word. This does not mean to remove reference to Microsoft Word Xxx Object Library, just alter your Dims like this
Dim oWord As Object '--- was Word.Application'
Dim oDoc As Object '--- was Word.Document'
...
oDoc.Protect wdAllowOnlyReading '--- keep using enums'
Could it be some 'rounding' difference? For instance if you compare two float point values for equality, the result can subtly depend on the specific compiler/interpreter implementation.
I would like to suggest to trim down your code to the minimum showing the different behaviors. That might clear things up already. If not, please post it here to let us help you.
Maybe you are running the compiled version as a different user than the one running VB when you debug? Maybe this could cause what you are describing, if the two users have some different Word settings.
Is it possible that the compiled version finds a different version of the .dot file?
It may be very helpful if you show the code you use to create the Word document, because then someone here might notice something that can be sensible to moving to a compiled version.
Do you have any code in events that rely on timing, such as Form_Activate, Load, or Unload? I've seen those things behave very differently when stepping through code and when compiled, especially on newer, faster machines.

Resources